开发者

Windows service always "Starting"

开发者 https://www.devze.com 2023-01-27 18:31 出处:网络
I\'ve got an app which I\'ve tested as wor开发者_如何学运维king as a console application. I\'ve now converted this to a Windows service, installed it, run it, and it still does it job.

I've got an app which I've tested as wor开发者_如何学运维king as a console application. I've now converted this to a Windows service, installed it, run it, and it still does it job.

However, it always has a status of Starting. There doesn't seem to be any logical flag to set on the ServiceBase.

I've setup the service with a bool isRunning flag, and the program runs within a while (isRunning) {} block.


Are you blocking the return of OnStart?

Normally one would spawn a thread from there to do the work, and let the method return.


It sounds as if you are not handing off the run in the startup phase.

  static void Main()
  {
     ServiceBase[] ServicesToRun;
     ServicesToRun = new ServiceBase[] { new myservice() };
     AppDomain currentDomain = AppDomain.CurrentDomain;
     currentDomain.UnhandledException += UnknownExceptionHandler;
     Run(ServicesToRun);
  }
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号