Namespace rouminsoft.demo {
Public class openprocess {
// static variable indicates the current program operation
Static bool isrunning = true;
Public static void main () {
// Establish a process object
System.Diagnostics.process p = new system.diagnostics.process ();
// Add this process end event handler
P.Exited = new system.eventhandler (openprocess.process_onexit);
p.enableraisingevents = true;
p.SynchronizingObject = NULL;
P.StartInfo.FileName = "Notepad.exe";
// Startup process
p.Start ();
/ / Keep the program
While (isrunning) {
System.Threading.Thread.Sleep (1000);
}
}
// Process end event handler
Static Void Process_OnExit (Object Sender, System.EventArgs E) {
System.windows.Forms.MessageBox.show ("Notepad Was Closed");
Isorunning = false;
/ / Set the marked to false
}
}
}