NanoByte.Common  2.8.1
NanoByte.Common.Tasks.CancellationTokenSource Class Reference

Signals to CancellationTokens that they should be canceled. More...

Inheritance diagram for NanoByte.Common.Tasks.CancellationTokenSource:
NanoByte.Common.MarshalNoTimeout

Public Member Functions

void Cancel ()
 Notifies all listening CancellationTokens that operations should be canceled. More...
 
override string ToString ()
 
void Dispose ()
 
- Public Member Functions inherited from NanoByte.Common.MarshalNoTimeout
override? object InitializeLifetimeService ()
 

Properties

CancellationToken Token [get]
 Gets a CancellationToken associated with this CancellationTokenSource. More...
 
bool IsCancellationRequested [get]
 Indicates whether Cancel has been called. More...
 
WaitHandle WaitHandle [get]
 Gets a wait handle that is signaled when see cref="Cancel"/> has been called. More...
 

Events

Action? CancellationRequested
 Raised the first time Cancel is called. Subsequent calls will not raise this event again. More...
 

Detailed Description

Signals to CancellationTokens that they should be canceled.

Unlike the built-in CancellationToken type of .NET the NanoByte.Common variant supports remoting.

Member Function Documentation

◆ Cancel()

void NanoByte.Common.Tasks.CancellationTokenSource.Cancel ( )
inline

Notifies all listening CancellationTokens that operations should be canceled.

Property Documentation

◆ IsCancellationRequested

bool NanoByte.Common.Tasks.CancellationTokenSource.IsCancellationRequested
get

Indicates whether Cancel has been called.

◆ Token

CancellationToken NanoByte.Common.Tasks.CancellationTokenSource.Token
get

Gets a CancellationToken associated with this CancellationTokenSource.

◆ WaitHandle

WaitHandle NanoByte.Common.Tasks.CancellationTokenSource.WaitHandle
getpackage

Gets a wait handle that is signaled when see cref="Cancel"/> has been called.

Event Documentation

◆ CancellationRequested

Action? NanoByte.Common.Tasks.CancellationTokenSource.CancellationRequested

Raised the first time Cancel is called. Subsequent calls will not raise this event again.

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


The documentation for this class was generated from the following file: