-
Book Overview & Buying
-
Table Of Contents
Visual Studio 2010 Best Practices
By :
There are two important types of threads in .NET: thread pool threads and non-thread pool threads. Thread pool threads are generally threads that are implicitly created or revived (or otherwise implicitly "re-used"). Non-thread pool threads are created and terminated manually and not re-used.
Creating a thread is an expensive proposition. Each thread has its own stack that defaults to 1 MB of memory. That memory needs to be allocated and committed. It is said that starting a thread can cost upwards of 200,000 cycles, and terminating a thread can cost upwards of 100,000 cycles (for a total cost of 300,000 cycles). Taking on that cost shouldn't be a trivial decision. Thread pool threads are managed by the .NET Framework and the operating system for your use, but their use also has caveats.
So, when should you decide to create your own thread or use the thread pool? Generally, if you need a CPU-intensive operation to be performed that could take upwards of several seconds, creating...
Change the font size
Change margin width
Change background colour