In this recipe, we will be looking at thread pools in C#. Basically, a thread pool is a collection of threads that can be used to perform tasks in the background. Once a thread completes its task, then it is sent to a pool of waiting threads, where it can be reused. Let's create a .NET Standard 2.0 library that uses thread pools.
- Open Visual Studio 2017.
- Click
File
|New
|Project
to create a project. - In the
New Project
dialog box, expand theOther Project Types
node in the left-hand pane and selectVisual Studio Solutions
. In the right-hand pane, selectBlank Solution
.
- In the
Name:
textbox, typeChapter6.ThreadPools
and, in theLocation:
textbox, select a path from the drop-down box or click on theBrowse...
button to locate a path:
- Click
OK
. - Now, the
Solution Explorer
(Ctrl + Alt + L) should look like this:
- Right-click on the
Chapter6.ThreadPools
label in theSolution...