Chapter 25. Creating Multithreaded Applications

Multithreading, the ability of an application to spawn several concurrent tasks, is something that many developers associate with complex applications that perform mighty deeds. However, as you'll discover in this chapter, multithreading is a technique that can benefit nearly any application when used correctly. By using multithreading correctly, you can make an application more responsive to user requests and use system resources more efficiently. In addition, you can perform tasks in the background that actually anticipate user needs — making the application appear clairvoyant.

This chapter isn't going to make you a guru on creating multithreaded applications. In fact, you'll barely see any code in this chapter. The point of this chapter is to discuss the ramifications of multithreading on your application design. The technique used to create multiple threads is well understood and documented, but the question of when and how to use multithreading is neither well known nor standardized. Many developers misuse multithreading techniques in their code because they don't fully understand the ramifications or requirements of using it to achieve a desired result.

You will see a basic multithreaded application in this chapter. The technique is actually quite simple. Of course, any simple technique can become complex under the right circumstances. Some application designs have a wealth of obscure code to control multithreaded operations. In ...

Get Expert One-on-One™ C# Design and Development 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.