WorkerSupportsCancellation Property
Collapse the table of content
Expand the table of content

BackgroundWorker.WorkerSupportsCancellation Property

[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]

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

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

public bool WorkerSupportsCancellation { get; set; }

Property Value

Type: System.Boolean
true if the BackgroundWorker supports cancellation; otherwise false. The default is false.

Set the WorkerSupportsCancellation property to true if you want the BackgroundWorker to support cancellation. When this property is true, you can call the CancelAsync method to interrupt a background operation.

When this property is false, calling the CancelAsync method will cause an InvalidOperationException.

The following code example demonstrates the use of the WorkerSupportsCancellation property to check whether a background operation allows cancellation before canceling it. To view the complete code for this sample, see How to use a background worker for Windows Phone 8.

private void buttonCancel_Click(object sender, RoutedEventArgs e)
    if (bw.WorkerSupportsCancellation == true)

Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Windows Phone

© 2017 Microsoft