ServiceBase.OnStop doesn't work properly

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

This is my repost:

(XP SP2, .NET Framework 1.1)

I created a windows service application, running system account and
interacting with desktop. Though the core was written in C#, it however
interfaced with unmanaged legacy library to control certain hardware with
callbacks (basically through serial port). The service also interfaced with
other applications through .NET remoting. However, I ran into problems in
stopping the service. Our OnStop functions not always got invoked (I
inserted debugger.launch in the OnStop function to catch the occurance) when
we stopped the service from the control panel - there is also no standard
patterns on when it would be called and when it wouldn't happen. I initiated
a ServiceController object inside one of the thread of this service to check
the Service Status as well as writing and external application using
ServiceController to monitor its status too. In both cases, I saw the
Service Status got changed to "Stopped", but the service "OnStop" was never
called. Finally, after a timeout about 20-30 seconds, the OS seemed to just
kill the service.

Did anybody have similar experience? How do the OS, and the framework linked
this callback to SCM??
 
Back
Top