The advantages of the ThreadPool are as follows:
- Threads can be utilized to free up the main thread.
- Threads are created and maintained in an optimal way by CLR.
The disadvantages of the ThreadPool are as follows:
- With more threads, the code becomes difficult to debug and maintain.
- We need to do exception handling inside the worker method as any unhandled exception can result in the program crashing.
- Progress reporting, cancellations, and completion logic need to be written from scratch.
The following are the reasons when we should avoid ThreadPool:
- When we need a foreground thread.
- When we need to set an explicit priority to a thread.
- When we have long-running or blocking ...