O'Reilly logo

ASP.NET Site Performance Secrets by Matt Perdeck

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

Threading

If used poorly, threading can consume a lot of CPU cycles needlessly. If your code is multi-threaded, consider the following ways to reduce threading overhead:

  • If you use threads to wait for off-box resources such as databases or web services, consider using asynchronous requests instead. These are described in Chapter 6,Thread Usage.
  • Do not create your own threads. This is very expensive. Instead, use ThreadPool.QueueUserWorkItem to get a thread from the thread pool.
  • Do not use threads for CPU-intensive tasks. If you have four CPUs, there is no sense in having more than four CPU-intensive tasks.
  • Thread switches are expensive. Try to reduce the number of threads running simultaneously.

To get more information about the threads currently ...

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