C # implement software to monitor the running state of external programs

Source: Internet
Author: User

In this paper, we describe the method of C # Implementing software to monitor the running state of external programs. Share to everyone for your reference. Here's how:

Need to plug a program to monitor another program running state, once detected another program shutdown, triggered an event to do other processing.

usingSystem.Diagnostics;//introducing the Process classPrivateprocess[] myprocesses; Myprocesses= Process.getprocessesbyname ("Sajetmanager");//The program name that needs to be monitored, this method takes out all the processes that the program usesforeach(Process myprocessinchmyprocesses) {TextBox1.Text+ = myprocess. ProcessName +"\ r \ n"; if(myprocess. Processname.tolower () = ="Sajetmanager") {MessageBox.Show ("Sajetmanager"); Myprocess. EnableRaisingEvents=true;//set the time to trigger when the process terminatesMyprocess. Exited + =NewEventHandler (myprocess_exited);//Discover external program shutdown is the trigger method myprocess_exited    }} Private voidMyprocess_exited (Objectsender, EventArgs e)//programs that are triggered{MessageBox.Show ("Sajetmanager Close");}

C # implement software to monitor the running state of external programs

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.