C # Winfrom Process & Multithreading

Source: Internet
Author: User

Process:

You first need to reference the namespace:

Using Systemdiagnostics;

The simplest way to open a process, the process name is not kanji:

Process.Start ("calc"); // CLAC is the calculator process, you can use this method to open the calculator Process.Start ("notepad"); // multiple processes can be opened at the same time, Notepad is Notepad

To open a process in a browse way:

//first, the path of a process is output to a textbox;//returns a bool typeDialogResult dr =Openfiledialog1.showdialog ();//Judgingif(Dr==diagloresult.ok) {TextBox1.Text=Openfiledialog.filename}//After you export the file path to a text box, open the path in the text box directlyProcess p =NewProcess;//start processing This information in a textboxProcessStartInfo psi =NewProcessStartInfo (TextBox1.Text);p. StartInfo=Psi;p.start ();

You can use Process.Start ("Chrome", "http://www.baidu.com") if you output a process with a specified browser.

The default browser direct output can be Process.Start ("http://www.baidu.com");

Multithreading:

Using System.Threading;

Thread.Sleep ();

A thread can only do one thing at a time;

Create a new thread (foreground thread):

The main thread has stopped, and the background threads continue to

// delegate's keyword Delegate New Thread (need to write a delegate, the delegate is pointing to a method, the delegate does not need to write parentheses, only need to write the method name); // When the thread is finished, it is deleted, and the new thread is re-added the next time the method is executed .

Background thread:

The main thread stops the background threads immediately;

New // Creating Objects true // setting up a background thread // Start Execution

"Off-Monitor" method:

false;

C # Winfrom Process & Multithreading

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.