C# service on stop not triggered

  • Thread starter Thread starter Jabba
  • Start date Start date
J

Jabba

Hello,
I've written a (quite complicated) windows service using C# ,
starting from a wizzard generated project.Added custom installers,
installs and run just fine, does all the work it's supposed to do.

I do not change the CanStop propery anywhere in the code.

But the OnStop protected overriden method is never triggered, and
thus, my cleanup code is never executed.

Searching the Internet high and low, I could not find a similar
problem.Everyone seems to be getting their onstop just fine.
Today, I've put together a simple service, straight out of the
wizzard and with the bare/minimum installers added.Again, the OnStop
doesn't trigger.

Any ideas?

Thanks,
Jabba
 
Sorry I can't offer any help, but I've had the same problem. the failure to
trigger the OnStop event and the inablity to easily debug the service
eventually led me to simply write a standard app instead. googling revealed
nothing of interest when I was still trying to figure it out. Although I
don't require it anymore, I'm still interrested in finding a solution to
this.

Chris LaJoie
 
Are you perhaps choking it out with too many cycles and not allowing
that thread to run? Are you using a very tight loop? Something like
for(;;){ ... }? are you erroring out? When a service throws an
exception it simply leaves the scope. No warning. No GUI. No nothing.
It just bubbles the error up to the main function or the first error
trap it finds. Are you using a premature return; statement?
 
Back
Top