Multithreading 101

Each application has a main thread of execution. This main thread executes the application code in some specific order; whether based on user interaction or in response to a Windows message. What happens when more than one task or section of code needs to be executed? The order of execution will depend on how the single-threaded application is developed, but only one task at a time will be executed.

Under the Windows environment, it is possible for an application to spawn several threads and to control the interaction of those threads. This allows an application to handle multiple tasks concurrently. Consider your favorite Web browser. When downloading a file, the Web browser will spawn a thread to handle that task and allow ...

Get C# and the .NET Framework: The C++ Perspective now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.