Class Continuation
Represents various continuations.
Inherited Members
Namespace: DotNext.Threading.Tasks
Assembly: DotNext.dll
Syntax
public static class Continuation
Methods
| Improve this Doc View SourceContinueWithTimeout<T>(Task<T>, TimeSpan, CancellationToken)
Attaches timeout and, optionally, token to the task.
Declaration
public static Task<T> ContinueWithTimeout<T>(this Task<T> task, TimeSpan timeout, CancellationToken token = default(CancellationToken))
Parameters
| Type | Name | Description |
|---|---|---|
| Task<T> | task | The source task. |
| TimeSpan | timeout | The timeout of the asynchronous task. |
| CancellationToken | token | The token that can be used to cancel the constructed task. |
Returns
| Type | Description |
|---|---|
| Task<T> | The task with attached timeout and token. |
Type Parameters
| Name | Description |
|---|---|
| T | The type of the task. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentOutOfRangeException |
|
| OperationCanceledException | The operation has been canceled. |
| TimeoutException | The timeout has occurred. |
OnCanceled<T, TConstant>(Task<T>, TaskScheduler)
Returns constant value if underlying task is canceled.
Declaration
public static Task<T> OnCanceled<T, TConstant>(this Task<T> task, TaskScheduler scheduler = null)
where TConstant : Constant<T>, new()
Parameters
| Type | Name | Description |
|---|---|---|
| Task<T> | task | The task to check. |
| TaskScheduler | scheduler | Optional scheduler used to schedule continuation. |
Returns
| Type | Description |
|---|---|
| Task<T> | The task representing continuation. |
Type Parameters
| Name | Description |
|---|---|
| T | The type of task result. |
| TConstant | The type describing constant value. |
Remarks
This continuation doesn't produce memory pressure. The delegate representing continuation is cached for future reuse as well as constant value.
OnCompleted(Task)
Allows to obtain original Task in its final state after await without
throwing exception produced by this task.
Declaration
public static Task<Task> OnCompleted(this Task task)
Parameters
| Type | Name | Description |
|---|---|---|
| Task | task | The task to await. |
Returns
| Type | Description |
|---|---|
| Task<Task> |
|
OnCompleted<TResult>(Task<TResult>)
Allows to obtain original Task<TResult> in its final state after await without
throwing exception produced by this task.
Declaration
public static Task<Task<TResult>> OnCompleted<TResult>(this Task<TResult> task)
Parameters
| Type | Name | Description |
|---|---|---|
| Task<TResult> | task | The task to await. |
Returns
| Type | Description |
|---|---|
| Task<Task<TResult>> |
|
Type Parameters
| Name | Description |
|---|---|
| TResult | The type of the task result. |
OnFaulted<T, TConstant>(Task<T>, TaskScheduler)
Returns constant value if underlying task is failed.
Declaration
public static Task<T> OnFaulted<T, TConstant>(this Task<T> task, TaskScheduler scheduler = null)
where TConstant : Constant<T>, new()
Parameters
| Type | Name | Description |
|---|---|---|
| Task<T> | task | The task to check. |
| TaskScheduler | scheduler | Optional scheduler used to schedule continuation. |
Returns
| Type | Description |
|---|---|
| Task<T> | The task representing continuation. |
Type Parameters
| Name | Description |
|---|---|
| T | The type of task result. |
| TConstant | The type describing constant value. |
Remarks
This continuation doesn't produce memory pressure. The delegate representing continuation is cached for future reuse as well as constant value.
OnFaultedOrCanceled<T, TConstant>(Task<T>, TaskScheduler)
Returns constant value if underlying task is failed or canceled.
Declaration
public static Task<T> OnFaultedOrCanceled<T, TConstant>(this Task<T> task, TaskScheduler scheduler = null)
where TConstant : Constant<T>, new()
Parameters
| Type | Name | Description |
|---|---|---|
| Task<T> | task | The task to check. |
| TaskScheduler | scheduler | Optional scheduler used to schedule continuation. |
Returns
| Type | Description |
|---|---|
| Task<T> | The task representing continuation. |
Type Parameters
| Name | Description |
|---|---|
| T | The type of task result. |
| TConstant | The type describing constant value. |
Remarks
This continuation doesn't produce memory pressure. The delegate representing continuation is cached for future reuse as well as constant value.