I have a windows service that starts a thread in the OnStart method.
Basically I want to be able to stop the service if something goes really wrong (like an unhandled exception).
Currently I'm using ServiceBase.Stop()
but that involves having a ServiceBase
instance somewhere visible to the thread, which in turn involves having my instance be declared as public static
in the main program.
Is there any "better way" to stop the service? If it isn't ... is it safe to do it that way?