开发者

Windows service always "Starting"

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜