Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.
0 out of 2 rated this helpful - Rate this topic

BackgroundWorker.RunWorkerAsync Method (Object)

Starts execution of a background operation.

Namespace: System.ComponentModel
Assembly: System (in system.dll)

public void RunWorkerAsync (
	Object argument
)
public void RunWorkerAsync (
	Object argument
)
public function RunWorkerAsync (
	argument : Object
)
Not applicable.

Parameters

argument

A parameter for use by the background operation to be executed in the DoWork event handler.

Exception typeCondition

InvalidOperationException

IsBusy is true.

The RunWorkerAsync method submits a request to start the operation running asynchronously. When the request is serviced, the DoWork event is raised, which in turn starts execution of your background operation.

If your operation requires a parameter, you can provide it as the argument parameter to RunWorkerAsync.

If the background operation is already running, calling RunWorkerAsync again will raise an InvalidOperationException.

The following code example demonstrates the use of the RunWorkerAsync method to start an asynchronous operation. This code example is part of a larger example provided for the BackgroundWorker class.

// Start the asynchronous operation.
backgroundWorker1.RunWorkerAsync(numberToCompute);

// Start the asynchronous operation.
backgroundWorker1.RunWorkerAsync(System.Convert.ToString
    (numberToCompute));

Windows 98, Windows Server 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

Show:
© 2014 Microsoft. All rights reserved.