Start a process and process the end event

xiaoxiao2021-03-06  109

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

}

}

}

转载请注明原文地址:https://www.9cbs.com/read-102885.html

New Post(0)