Class Cancelable
A ICancelable that wraps a CancellationTokenSource. When canceling this instance the underlying CancellationTokenSource is canceled as well.
Inherited Members
Namespace: Akka.Actor
Assembly: Akka.dll
Syntax
public class Cancelable : ICancelable, IDisposable
Constructors
| Improve this Doc View SourceCancelable(IActionScheduler)
Initializes a new instance of the Cancelable class.
Declaration
public Cancelable(IActionScheduler scheduler)
Parameters
Type | Name | Description |
---|---|---|
IActionScheduler | scheduler | TBD |
Cancelable(IActionScheduler, TimeSpan)
Initializes a new instance of the Cancelable class that will be cancelled after the specified amount of time.
Declaration
public Cancelable(IActionScheduler scheduler, TimeSpan delay)
Parameters
Type | Name | Description |
---|---|---|
IActionScheduler | scheduler | The scheduler. |
TimeSpan | delay | The delay before the cancelable is canceled. |
Cancelable(IScheduler)
Initializes a new instance of the Cancelable class.
Declaration
public Cancelable(IScheduler scheduler)
Parameters
Type | Name | Description |
---|---|---|
IScheduler | scheduler | TBD |
Cancelable(IScheduler, Int32)
Initializes a new instance of the Cancelable class that will be cancelled after the specified amount of milliseconds.
Declaration
public Cancelable(IScheduler scheduler, int millisecondsDelay)
Parameters
Type | Name | Description |
---|---|---|
IScheduler | scheduler | The scheduler. |
Int32 | millisecondsDelay | The delay in milliseconds. |
Cancelable(IScheduler, TimeSpan)
Initializes a new instance of the Cancelable class that will be cancelled after the specified amount of time.
Declaration
public Cancelable(IScheduler scheduler, TimeSpan delay)
Parameters
Type | Name | Description |
---|---|---|
IScheduler | scheduler | The scheduler. |
TimeSpan | delay | The delay before the cancelable is canceled. |
Properties
| Improve this Doc View SourceIsCancellationRequested
Gets a value indicating whether cancellation has been requested
Declaration
public bool IsCancellationRequested { get; }
Property Value
Type | Description |
---|---|
Boolean |
IsDisposed
Declaration
public bool IsDisposed { get; }
Property Value
Type | Description |
---|---|
Boolean |
Token
Gets the CancellationToken associated with this ICancelable.
Declaration
public CancellationToken Token { get; }
Property Value
Type | Description |
---|---|
CancellationToken |
Methods
| Improve this Doc View SourceCancel()
Communicates a request for cancellation.
Declaration
public void Cancel()
Remarks
The associated cancelable will be notified of the cancellation and will transition
to a state where IsCancellationRequested returns true
.
Any callbacks or cancelable operations registered with the cancelable will be executed.
Cancelable operations and callbacks registered with the token should not throw exceptions.
However, this overload of Cancel will aggregate any exceptions thrown into an
AggregateException, such that one callback throwing an exception will not
prevent other registered callbacks from being executed.
The ExecutionContext that was captured when each callback was registered will
be reestablished when the callback is invoked.
Cancel(Boolean)
Communicates a request for cancellation, and specifies whether remaining callbacks and cancelable operations should be processed.
Declaration
public void Cancel(bool throwOnFirstException)
Parameters
Type | Name | Description |
---|---|---|
Boolean | throwOnFirstException |
|
Remarks
The associated cancelable will be notified of the cancellation and will transition
to a state where IsCancellationRequested returns true
.
Any callbacks or cancelable operations registered with the cancelable will be executed.
Cancelable operations and callbacks registered with the token should not throw exceptions.
If throwOnFirstException
is true
, an exception will immediately
propagate out of the call to Cancel, preventing the remaining callbacks and cancelable operations
from being processed.
If throwOnFirstException
is false
, this overload will aggregate any exceptions
thrown into an AggregateException, such that one callback throwing an exception will not
prevent other registered callbacks from being executed.
The ExecutionContext that was captured when each callback was registered will be
reestablished when the callback is invoked.
CancelAfter(Int32)
Schedules a cancel operation on this cancelable after the specified number of milliseconds.
Declaration
public void CancelAfter(int millisecondsDelay)
Parameters
Type | Name | Description |
---|---|---|
Int32 | millisecondsDelay | The delay in milliseconds before this instance is canceled. |
CancelAfter(TimeSpan)
Schedules a cancel operation on this cancelable after the specified delay.
Declaration
public void CancelAfter(TimeSpan delay)
Parameters
Type | Name | Description |
---|---|---|
TimeSpan | delay | The delay before this instance is canceled. |
CreateCanceled()
Returns a ICancelable that has already been canceled.
Declaration
public static ICancelable CreateCanceled()
Returns
Type | Description |
---|---|
ICancelable |
CreateLinkedCancelable(IActionScheduler, ICancelable[])
Creates a ICancelable that will be in the canceled state when any of the source cancelables are in the canceled state.
Declaration
public static ICancelable CreateLinkedCancelable(IActionScheduler scheduler, params ICancelable[] cancelables)
Parameters
Type | Name | Description |
---|---|---|
IActionScheduler | scheduler | The scheduler |
ICancelable[] | cancelables | The cancelables instances to observe. |
Returns
Type | Description |
---|---|
ICancelable | A new ICancelable that is linked to the source . |
CreateLinkedCancelable(IActionScheduler, CancellationToken[])
Declaration
public static ICancelable CreateLinkedCancelable(IActionScheduler scheduler, params CancellationToken[] cancellationTokens)
Parameters
Type | Name | Description |
---|---|---|
IActionScheduler | scheduler | |
CancellationToken[] | cancellationTokens |
Returns
Type | Description |
---|---|
ICancelable |
CreateLinkedCancelable(IScheduler, ICancelable[])
Creates a ICancelable that will be in the canceled state when any of the source cancelables are in the canceled state.
Declaration
public static ICancelable CreateLinkedCancelable(IScheduler scheduler, params ICancelable[] cancelables)
Parameters
Type | Name | Description |
---|---|---|
IScheduler | scheduler | The scheduler |
ICancelable[] | cancelables | The cancelables instances to observe. |
Returns
Type | Description |
---|---|
ICancelable | A new ICancelable that is linked to the source . |
CreateLinkedCancelable(IScheduler, CancellationToken[])
Declaration
public static ICancelable CreateLinkedCancelable(IScheduler scheduler, params CancellationToken[] cancellationTokens)
Parameters
Type | Name | Description |
---|---|---|
IScheduler | scheduler | |
CancellationToken[] | cancellationTokens |
Returns
Type | Description |
---|---|
ICancelable |
Dispose()
Declaration
public void Dispose()
Dispose(Boolean)
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
Declaration
protected virtual void Dispose(bool disposing)
Parameters
Type | Name | Description |
---|---|---|
Boolean | disposing | if set to |