Multithreading in Components
The BackgroundWorker component implements some of the threading features in the System.Threading namespace; the BackgroundWorker component is the easier way to implement multithreading functionality. For more information, see BackgroundWorker Component Overview.
Multithreading, or free threading, is the ability of an application to execute multiple threads of operation simultaneously. An example of a multithreaded application is a program that receives user input on one thread, performs a variety of complex calculations on a second thread, and updates a database on a third thread. In a single-threaded application, a user may spend idle time waiting for the calculations or database updates to finish. In a multithreaded application, these processes can proceed in the background so the user's time is not wasted.
Multithreading can be a powerful tool in component programming. By writing multithreaded components, you can create components that perform complex calculations in the background while leaving the user interface (UI) free to respond to user input.
Although multithreading can be a powerful tool, it can also be difficult to apply correctly. Improperly implemented multithreaded code can degrade application performance, or even cause frozen applications. The following topics introduce you to some of the considerations and best practices for multithreaded programming.
The .NET Framework offers several options for multithreading in components. The functionality in the System.Threading namespace is one option. The event-based asynchronous pattern is another. The BackgroundWorker component is an implementation of the asynchronous pattern; it gives you that advanced functionality encapsulated in a component for ease of use.
In This Section
- Multithreaded Programming for Components with System.Threading
Describes the use of the System.Threading namespace to create multithreaded components.
Enables you to run an operation on a separate, dedicated thread.
Provides information about syntax and members from the .NET Framework reference.
Multithreaded Programming with the Event-based Asynchronous Pattern
Describes the standardized way to package a component that has asynchronous features.
Multithreading in Visual Basic
Provides links to a variety of topics about using multithreading with Visual Basic.
Managed Threading Best Practices
Provides guidelines for using managed threading features.