I have the following code to identify whether a process has exited or not. When it exits I am creating a notification in my application.
Process[] processes = RunningInstancesByName("MyService");
while (processes.Length <= 0)
{
//Thread.Sleep(100);
processes = RunningInstancesByName(name);
}
Process process = processes[0];
process.EnableRaisingEvents = true;
process.Exited += this.Installer_Process_Exited;
AddExitEvents(name, eventHandler);
return process;
}
How do I identify whether this exit was triggered by a Windows shutdown or restart? Because if it is so, I should not create a notification through my application? Is there a way to identify whether this process exited because of such shut down or restart events? Please advice.