ServiceBase.OnStop doesn't work properly

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??
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top