C# Class NanoByte.Common.Tasks.CancellationToken

ファイルを表示 Open project: nano-byte/common Class Usage Examples

Public Methods

Method Description
Register ( System.Action callback ) : CancellationTokenRegistration

Registers a delegate that will be called when cancellation has been requested.

The callback is called from a background thread. Wrap via synchronization context to update UI elements. Handling this blocks the task, therefore observers should handle the event quickly.

ThrowIfCancellationRequested ( ) : void

Throws an OperationCanceledException if cancellation has been requested.

ToString ( ) : string

Private Methods

Method Description
CancellationToken ( CancellationTokenSource source ) : System

Creates a new token controlled by a specific CancellationTokenSource.

Method Details

Register() public method

Registers a delegate that will be called when cancellation has been requested.
The callback is called from a background thread. Wrap via synchronization context to update UI elements. Handling this blocks the task, therefore observers should handle the event quickly.
public Register ( System.Action callback ) : CancellationTokenRegistration
callback System.Action The delegate to be executed when cancellation has been requested.
return CancellationTokenRegistration

ThrowIfCancellationRequested() public method

Throws an OperationCanceledException if cancellation has been requested.
Cancellation has been requested.
public ThrowIfCancellationRequested ( ) : void
return void

ToString() public method

public ToString ( ) : string
return string