V
Vlad
I have a windows service that spawns several threads. One of those threads
may catch an exception that will require the whole service to shutdown. What
is the proper way to do it? I did some search on this subject, and the only
thing that I found is to create an instance of ServiceController and call
its Stop() method:
System.ServiceProcess.ServiceController sc = new
System.ServiceProcess.ServiceController("my Service Name");
sc.Stop();
This does not seem to work when I do it from a thread created by my service.
I'd like to avoid using System.Environment.Exit() since I am looking for a
solution that will cause OnStop() method of my service to be invoked prior
to termination of my service.
Any help would be greatly appreciated.
Vlad.
may catch an exception that will require the whole service to shutdown. What
is the proper way to do it? I did some search on this subject, and the only
thing that I found is to create an instance of ServiceController and call
its Stop() method:
System.ServiceProcess.ServiceController sc = new
System.ServiceProcess.ServiceController("my Service Name");
sc.Stop();
This does not seem to work when I do it from a thread created by my service.
I'd like to avoid using System.Environment.Exit() since I am looking for a
solution that will cause OnStop() method of my service to be invoked prior
to termination of my service.
Any help would be greatly appreciated.
Vlad.