C#threadpool and Thread

Source: Internet
Author: User
Tags net thread

  1. void Example ()
  2. {
  3. //Connect the Processfile method to the thread pool.
  4. //Note: ' A ' is an object that is a parameter
  5. ThreadPool.QueueUserWorkItem (new WaitCallback (Processfile), a);
  6. }
  7. Private void Processfile (object a)
  8. {
  9. //I was connected to the thread pool via WaitCallback.
  10. }

This section of thread pool is called first, and the thread class is relatively simple to use.

Thread thread = new Thread (faction);

Thread.Start ();

Because this piece of thread is often used, it has not been considered the use of this piece of threads before, in the study. NET thread hosting, it feels that the thread pool is more secure than thread usage when it is available.

MSDN says: "The thread pool is often used in server applications where each new requirement is assigned to a thread in a thread pool so that the requirement can be executed asynchronously without blocking the main thread or delaying the processing of subsequent requirements." ”

However, if the amount of processing is large, or some of the functions of an infinite loop are put into the thread pool, it may cause the thread pool queue to wait indefinitely, so I now understand some of the processing of thread pooling for short-term sex.

such as server data interception, but for video capture this efficient real-time processing or using thread.

C#threadpool and Thread

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.