Export (0) Print
Expand All

BackgroundWorker.IsBusy Property

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

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

public bool IsBusy { get; }
/** @property */
public boolean get_IsBusy ()

public function get IsBusy () : boolean

Not applicable.

Property Value

true, if the BackgroundWorker is running an asynchronous operation; otherwise, false.

The BackgroundWorker starts an asynchronous operation when you call RunWorkerAsync.

The following code example demonstrates how to use the IsBusy property to wait for completion of a BackgroundWorker operation. This code example is part of a larger example described in How to: Download a File in the Background.

private void dowloadButton_Click(object sender, EventArgs e)
{
    // Start the download operation in the background.
    this.backgroundWorker1.RunWorkerAsync();

    // Disable the button for the duration of the download.
    this.dowloadButton.Enabled = false;

    // Wait for the BackgroundWorker to finish the download.
    while (this.backgroundWorker1.IsBusy)
    {
        // Keep UI messages moving, so the form remains 
        // responsive during the asynchronous operation.
        Application.DoEvents();
    }

    // The download is done, so enable the button.
    this.dowloadButton.Enabled = true;
}

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

Community Additions

ADD
Show:
© 2014 Microsoft