O'Reilly logo

C# 2008 and 2005 Threaded Programming: Beginner's Guide by Gastón C. Hillar

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action - Creating the methods for queuing requests

Now, we are going to write some code in methods to use the Encrypter class and to queue requests using a pool of threads provided by the ThreadPool class:

  1. Stay in the project, MarsEncrypter.
  2. Open the code for the Windows Form Form1 (frmMarsEncrypter).
  3. Add the following line of code at the beginning (as we are going to use the System.Threading.ThreadPool class):
    using System.Threading;
    
  4. Open the Form Load event, and enter the following code—it is convenient to configure some ThreadPool class parameters to achieve optimal results:
    // Set the maximum number of requests to the thread pool that can be active concurrently equal to the number of available cores // All requests above that number remain ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required