How it works...

From the console application, we can see that the processor count is 2. The minimum number of thread pool threads, therefore, also equals 2. We then read the maximum thread pool size and generate a random number between the minimum and maximum numbers. Lastly, we set the maximum thread pool size, to our randomly generated minimum and maximum.

While this is only a proof of concept and not something one would do in a production application (setting the thread pool to a random number), it clearly illustrates the ability to set the thread pool to a value specified by the developer.

The code in this recipe was compiled for 32-bit. Try changing your application to a 64-bit application and run the code again. See the difference a ...

Get C# 7 and .NET Core Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.