I have a service that I would like it to become single instance, because when i click restart on services.msc, the new instance of the service starts when the old instance still haven't finished (because it has to perform some actions).
The code that finishes the service looks like this:
protected override void OnStop()
{
Log.Info("STOPPING SERVICE");
//Wait working threads to finish
_Worker.Die();
//Kill inner processes still running (sometimes some processes hang up and is the only way to kill them...
ProcessUtility.KillTree(System.Diagnostics.Process.GetCurrentProcess().Id);
//Call parent's class Stop
base.OnStop();
}
The class is a subclass of ServiceBase.
How can I make the new instance to only start when the old one has finished?
thx stackpowerflowers!!