Reputation: 5428
I've got an app which I've tested as working 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.
Upvotes: 2
Views: 2825
Reputation: 4392
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);
}
Upvotes: 0
Reputation: 117220
Are you blocking the return of OnStart
?
Normally one would spawn a thread from there to do the work, and let the method return.
Upvotes: 9