2014-09-10 33 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(); 

     });