System.ComponentModel.BackgroundWorker Class

Executes an operation on a separate thread.

See Also: BackgroundWorker


public class BackgroundWorker : Component


The BackgroundWorker class allows you to run an operation on a separate, dedicated thread. Time-consuming operations like downloads and database transactions can cause your user interface (UI) to seem as though it has stopped responding while they are running. When you want a responsive UI and you are faced with long delays associated with such operations, the BackgroundWorker class provides a convenient solution.

To execute a time-consuming operation in the background, create a BackgroundWorker and listen for events that report the progress of your operation and signal when your operation is finished. You can create the BackgroundWorker programmatically or you can drag it onto your form from the Components tab of the Toolbox. If you create the BackgroundWorker in the Windows Forms Designer, it will appear in the Component Tray, and its properties will be displayed in the Properties window.

To set up for a background operation, add an event handler for the BackgroundWorker.DoWork event. Call your time-consuming operation in this event handler. To start the operation, call BackgroundWorker.RunWorkerAsync. To receive notifications of progress updates, handle the BackgroundWorker.ProgressChanged event. To receive a notification when the operation is completed, handle the BackgroundWorker.RunWorkerCompleted event.


You must be careful not to manipulate any user-interface objects in your BackgroundWorker.DoWork event handler. Instead, communicate to the user interface through the BackgroundWorker.ProgressChanged and BackgroundWorker.RunWorkerCompleted events.

BackgroundWorker events are not marshaled across AppDomain boundaries. Do not use a BackgroundWorker component to perform multithreaded operations in more than one AppDomain.

If your background operation requires a parameter, call BackgroundWorker.RunWorkerAsync with your parameter. Inside the BackgroundWorker.DoWork event handler, you can extract the parameter from the DoWorkEventArgs.Argument property.

For more information about BackgroundWorker, see How to: Run an Operation in the Background.


Namespace: System.ComponentModel
Assembly: System (in System.dll)
Assembly Versions:,
Since: .NET 2.0

The members of System.ComponentModel.BackgroundWorker are listed below.

See Also: Component

Public Constructors

Initializes a new instance of the BackgroundWorker class.

Public Properties


Gets a value indicating whether the application has requested cancellation of a background operation.


Gets a value indicating whether the BackgroundWorker is running an asynchronous operation.


Gets or sets a value indicating whether the BackgroundWorker can report progress updates.


Gets or sets a value indicating whether the BackgroundWorker supports asynchronous cancellation.

Public Methods


Requests cancellation of a pending background operation.


Raises the BackgroundWorker.ProgressChanged event.

ReportProgress(Int32, Object)

Raises the BackgroundWorker.ProgressChanged event.


Starts execution of a background operation.


Starts execution of a background operation.

Protected Methods

Public Events


Occurs when BackgroundWorker.RunWorkerAsync is called.


Occurs when BackgroundWorker.ReportProgress(Int32) is called.


Occurs when the background operation has completed, has been canceled, or has raised an exception.