Skip to main content

TaskExtensions

Provides synchronous extension methods for tasks.

Assembly: ServiceStack.Common.dll
View Source
Declaration
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
Declaration
public static Task WaitAsync(this Task this, CancellationToken cancellationToken)
Returns

System.Threading.Tasks.Task

Parameters
TypeNameDescription
System.Threading.Tasks.TaskthisThe 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
Declaration
public static void WaitAndUnwrapException(this Task task)
Parameters
TypeNameDescription
System.Threading.Tasks.TasktaskThe task. May not be null.

|

WaitAndUnwrapException(Task, CancellationToken)

Waits for the task to complete, unwrapping any exceptions.

View Source
Declaration
public static void WaitAndUnwrapException(this Task task, CancellationToken cancellationToken)
Parameters
TypeNameDescription
System.Threading.Tasks.TasktaskThe 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
Declaration
public static TResult WaitAndUnwrapException<TResult>(this Task<TResult> task)
Returns

<TResult>: The result of the task.

Parameters
TypeNameDescription
System.Threading.Tasks.Task<<TResult>>taskThe task. May not be null.

|

Type Parameters
NameDescription
TResultThe type of the result of the task.

WaitAndUnwrapException<TResult>(Task<TResult>, CancellationToken)

Waits for the task to complete, unwrapping any exceptions.

View Source
Declaration
public static TResult WaitAndUnwrapException<TResult>(this Task<TResult> task, CancellationToken cancellationToken)
Returns

<TResult>: The result of the task.

Parameters
TypeNameDescription
System.Threading.Tasks.Task<<TResult>>taskThe task. May not be null.

| | System.Threading.CancellationToken | cancellationToken | A cancellation token to observe while waiting for the task to complete.

|

Type Parameters
NameDescription
TResultThe 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
Declaration
public static void WaitWithoutException(this Task task)
Parameters
TypeNameDescription
System.Threading.Tasks.TasktaskThe 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
Declaration
public static void WaitWithoutException(this Task task, CancellationToken cancellationToken)
Parameters
TypeNameDescription
System.Threading.Tasks.TasktaskThe task. May not be null.

| | System.Threading.CancellationToken | cancellationToken | A cancellation token to observe while waiting for the task to complete.

|