TaskExtensions
Provides synchronous extension methods for tasks.
Assembly: ServiceStack.Common.dll
View Source
public static class TaskExtensions
Methods
WaitAsync(Task, CancellationToken)
Asynchronously waits for the task to complete, or for the cancellation token to be canceled.
View Source
public static Task WaitAsync(this Task this, CancellationToken cancellationToken)
Returns
System.Threading.Tasks.Task
Parameters
Type | Name | Description |
---|---|---|
System.Threading.Tasks.Task | this | The task to wait for. May not be null . |
|
| System.Threading.CancellationToken
| cancellationToken | The cancellation token that cancels the wait.
|
WaitAndUnwrapException(Task)
Waits for the task to complete, unwrapping any exceptions.
View Source
public static void WaitAndUnwrapException(this Task task)
Parameters
Type | Name | Description |
---|---|---|
System.Threading.Tasks.Task | task | The task. May not be null . |
|
WaitAndUnwrapException(Task, CancellationToken)
Waits for the task to complete, unwrapping any exceptions.
View Source
public static void WaitAndUnwrapException(this Task task, CancellationToken cancellationToken)
Parameters
Type | Name | Description |
---|---|---|
System.Threading.Tasks.Task | task | The task. May not be null . |
|
| System.Threading.CancellationToken
| cancellationToken | A cancellation token to observe while waiting for the task to complete.
|
WaitAndUnwrapException<TResult>(Task<TResult>)
Waits for the task to complete, unwrapping any exceptions.
View Source
public static TResult WaitAndUnwrapException<TResult>(this Task<TResult> task)
Returns
<TResult>
: The result of the task.
Parameters
Type | Name | Description |
---|---|---|
System.Threading.Tasks.Task<<TResult>> | task | The task. May not be null . |
|
Type Parameters
Name | Description |
---|---|
TResult | The type of the result of the task. |
WaitAndUnwrapException<TResult>(Task<TResult>, CancellationToken)
Waits for the task to complete, unwrapping any exceptions.
View Source
public static TResult WaitAndUnwrapException<TResult>(this Task<TResult> task, CancellationToken cancellationToken)
Returns
<TResult>
: The result of the task.
Parameters
Type | Name | Description |
---|---|---|
System.Threading.Tasks.Task<<TResult>> | task | The task. May not be null . |
|
| System.Threading.CancellationToken
| cancellationToken | A cancellation token to observe while waiting for the task to complete.
|
Type Parameters
Name | Description |
---|---|
TResult | The type of the result of the task. |
WaitWithoutException(Task)
Waits for the task to complete, but does not raise task exceptions. The task exception (if any) is unobserved.
View Source
public static void WaitWithoutException(this Task task)
Parameters
Type | Name | Description |
---|---|---|
System.Threading.Tasks.Task | task | The task. May not be null . |
|
WaitWithoutException(Task, CancellationToken)
Waits for the task to complete, but does not raise task exceptions. The task exception (if any) is unobserved.
View Source
public static void WaitWithoutException(this Task task, CancellationToken cancellationToken)
Parameters
Type | Name | Description |
---|---|---|
System.Threading.Tasks.Task | task | The task. May not be null . |
|
| System.Threading.CancellationToken
| cancellationToken | A cancellation token to observe while waiting for the task to complete.
|