次の方法で共有


BackgroundWorker.IsBusy Property

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Gets a value that indicates whether the BackgroundWorker is running a background operation.

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

Syntax

'Declaration
Public ReadOnly Property IsBusy As Boolean
public bool IsBusy { get; }

Property Value

Type: System.Boolean
true , if the BackgroundWorker is running a background operation; otherwise, false.

Remarks

The BackgroundWorker starts a background operation when you call the RunWorkerAsync method. If the background worker's IsBusy property is true, calling RunWorkerAsync again will raise an InvalidOperationException.

Examples

The following code example demonstrates the use of the IsBusy property to check whether a background operation is already running before starting it. To view the complete code for this sample, see How to: Use a Background Worker.

Private Sub buttonStart_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs)
    If Not bw.IsBusy = True Then
        bw.RunWorkerAsync()
    End If
End Sub
private void buttonStart_Click(object sender, RoutedEventArgs e)
{
    if (bw.IsBusy != true)
    {
        bw.RunWorkerAsync();
    }
}

Version Information

Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

XNA Framework

Supported in: Xbox 360, Windows Phone OS 7.0

Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.