Hi,
It's simple:
private void StartProcess(string fileName)
{
var process = new Process();
process.StartInfo = new ProcessStartInfo(fileName);
process.EnableRaisingEvents = true;
process.Exited += new EventHandler(process_Exited);
process.Start();
}
private void process_Exited(object sender, EventArgs e)
{
MessageBox.Show("Process closed");
}
More informations about processes you will find here:
http://msdn.microsoft.com/pl-pl/library/system.diagnostics.process%28v=vs.110%29.aspx[
^]
Hope it helps you.
[Update]
Sorry, I didn't read too carefuly your question. But my answer may have a solution for you. You can monitor when your application was closed and restart it . Many applications (or services) uses similar solution.
Create simple agent (monitor) application which will be started by your application. Agent (monitor) after start will find your main application process and will keep and eye for it. In case user closes your main application agent will restart it.
Or you can start your application in you main window Closed event:
private void MainForm_FormClosed(object sender, FormClosedEventArgs e)
{
StartProcess("Your_APP_ExePath");
}
You can save some settings to restore application state after restart.
Hope this time will really help you :)