Esporta (0) Stampa
Espandi tutto

BackgroundWorker.CancellationPending Property

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

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

'Dichiarazione
Public ReadOnly Property CancellationPending As Boolean

Property Value

Type: System.Boolean
true if the application has requested cancellation of a background operation; otherwise, false. The default is false.

If the CancellationPending property is true, then the CancelAsync method has been called on the BackgroundWorker.

This property is meant for use by the background operation, which should periodically check CancellationPending and stop the background operation when it is set to true.

The following code example demonstrates the use of the CancellationPending property to query a BackgroundWorker about its cancellation state. To view the complete code for this sample, see How to: Use a Background Worker.


Private Sub bw_DoWork(ByVal sender As Object, ByVal e As DoWorkEventArgs)
    Dim worker As BackgroundWorker = CType(sender, BackgroundWorker)

    For i = 1 To 10
        If bw.CancellationPending = True Then
            e.Cancel = True
            Exit For
        Else
            ' Perform a time consuming operation and report progress.
            System.Threading.Thread.Sleep(500)
            bw.ReportProgress(i * 10)
        End If
    Next
End Sub


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

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

Aggiunte alla community

AGGIUNGI
Mostra:
© 2014 Microsoft