Chapter 8. Multithreading with .NET

I l @ ve RuBoard

A thread is the unit of execution that the operating system uses to run an application. Every application running under Microsoft Windows requires at least one thread. Since its earliest days, the Win32 platform has supported multithreading, which allows multiple concurrent paths of execution through a process. The major benefit of using multiple threads in applications has been better performance, both perceived and real. Perceived performance can be enhanced, for example, by ensuring that a distinct thread handles the processing for user interactions in a GUI application. This user interaction thread can run at a slightly higher priority while background tasks are performed on lower-priority threads. This arrangement makes the application as a whole more responsive to user input and makes it appear to the user that the application is faster, although the overall real performance doesn't really change. Real performance improvement is realized on multiprocessor machines, when separate threads in the same process can be executed truly concurrently.

Using multiple threads can make the developer's life simpler. Many modern applications require that a number of simultaneous tasks be performed ”gathering input from multiple sources (users, files, the network), processing data, formatting and outputting results, and so on. Without using multiple threads, a developer might be forced to use complicated logic and polling to perform these tasks.

On the other hand, the injudicious use of threads can make life difficult for a developer, especially if multiple threads need to access shared data. Synchronization can be a knotty problem if it's not approached correctly.

Threads themselves have become an integral part of the Windows operating system, and many parts of the Microsoft .NET platform rely on them for everyday tasks. In this chapter, we'll look at how the .NET Framework Class Library exposes the threading capabilities of Windows.

I l @ ve RuBoard


Microsoft Visual J# .NET (Core Reference)
Microsoft Visual J# .NET (Core Reference) (Pro-Developer)
ISBN: 0735615500
EAN: 2147483647
Year: 2002
Pages: 128

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net