2014-09-10 50 views
0

當我在配置中繼續添加時,Topshelf不起作用。它使用啓動和停止方法正常工作。我沒有任何代碼繼續方法,將阻止它運行(簡單的console.writeline)Topshelf When Continuing not working

HostFactory.Run(x => 
      { 
       x.SetDescription("Data Service - POC"); 
       x.SetDisplayName("Data Service"); 
       x.SetServiceName("DataService"); 
       x.EnablePauseAndContinue(); 
       x.Service<SampleService>(s => 
       { 
        s.ConstructUsing(() => new SampleService());      
        s.WhenStarted(v => v.Start());     
        s.WhenStopped(v => v.Stop()); 
        // s.WhenContinued(v => v.Continue()); 

       }); 
       x.RunAsLocalSystem(); 

      }); 

我錯過了什麼?

它編譯的很好。它沒有調用我的任何方法。我看到控制檯閃爍並消失。我什至不能讀那個控制檯上的東西。如果我註釋掉這行s.WhenContinued(v => v.Continue());它工作正常

+0

你是什麼意思「不工作」?不編譯,拋出異常,還有其他的東西? – stuartd 2014-09-12 10:53:06

+0

這是編譯好。它沒有調用我的任何方法。我看到控制檯閃爍並消失。我什至不能讀那個控制檯上的東西。如果我註釋掉這行s.WhenContinued(v => v.Continue());它工作正常 – 2014-09-13 17:36:52

回答

0

它也需要暫停配置。一旦我添加暫停方法配置它開始工作。

HostFactory.Run(x => 
     { 
      x.SetDescription("Data Service - POC"); 
      x.SetDisplayName("Data Service"); 
      x.SetServiceName("DataService"); 
      x.EnablePauseAndContinue(); 
      x.Service<SampleService>(s => 
      { 
       s.ConstructUsing(() => new SampleService());      
       s.WhenStarted(v => v.Start());     
       s.WhenStopped(v => v.Stop()); 
       s.WhenPaused(v => v.AnotherPause()); 
       s.WhenContinued(v => v.Continue()); 

      }); 
      x.RunAsLocalSystem(); 

     });