Shows how to use Thread Pooling in C#.
This application demonstrates three uses of the Thread pool in .NET:
1. Function Queuing
This demonstration compares running three processes in sequential order, using three dedicated threads, and using ThreadPool.QueueUserWorkItem. It displays the thread numbers for each process so you can see how the processes are distributed across the threads. You are able to select between low CPU usage processes and high intensity process to see how it affects the outcome of each process. The QueueUserWorkItem function executes the processes according to CPU availability, so the results should be different from having dedicated threads.
2. Timers:
This demonstration shows how to set up timed callbacks using the Threading.Timer class, which uses the ThreadPool. It displays the thread number, showing how the ThreadPool manages the threads to fire the timer callbacks.
3. Synchronization Objects:
This demonstration shows how to use the ThreadPool to run processes that wait for synchronization objects to be set/released without using dedicated threads that use blocking to monitor the synchronization object changes. This shows how to use the three synchronization objects derived from WaitHandle: Mutex, ManualResetEvent, and AutoResetEvent.
Simply press F5.
To fully appreciate what is happening in each of the above demonstrations, it is helpful to open the task manager to display CPU usage.