- void Example ()
- {
- //Connect the Processfile method to the thread pool.
- //Note: ' A ' is an object that is a parameter
- ThreadPool.QueueUserWorkItem (new WaitCallback (Processfile), a);
- }
- Private void Processfile (object a)
- {
- //I was connected to the thread pool via WaitCallback.
- }
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