-
-
Notifications
You must be signed in to change notification settings - Fork 358
TaskExtensions
Stephen Cleary edited this page May 30, 2016
·
2 revisions
TaskExtensions
provides one method OrderByCompletion
which orders a sequence of Tasks by when they complete. The approach taken by AsyncEx is a combination of Jon Skeet's approach and Stephen Toub's approach.
TaskExtensions
in the Nito.AsyncEx.Synchronous
namespace provides a handful of extension methods that enable synchronous blocking of a Task
without wrapping its exception in an AggregateException
, or without observing the Task
exception at all. These are advanced methods that should probably not be used, since you run the risk of a deadlock.
public static class TaskExtensions
{
// Creates a new array of tasks which complete in order.
public static Task<T>[] OrderByCompletion<T>(this IEnumerable<Task<T>> tasks);
}
// (in namespace Nito.AsyncEx.Synchronous):
public static class TaskExtensions
{
// Waits for the task to complete, unwrapping any exceptions.
public static void WaitAndUnwrapException(this Task task);
// Waits for the task to complete, unwrapping any exceptions.
public static void WaitAndUnwrapException(this Task task, CancellationToken cancellationToken);
// Waits for the task to complete, unwrapping any exceptions.
public static TResult WaitAndUnwrapException<TResult>(this Task<TResult> task);
// Waits for the task to complete, unwrapping any exceptions.
public static TResult WaitAndUnwrapException<TResult>(this Task<TResult> task, CancellationToken cancellationToken);
// Waits for the task to complete, but does not raise task exceptions. The task exception (if any) is unobserved.
public static void WaitWithoutException(this Task task);
// Waits for the task to complete, but does not raise task exceptions. The task exception (if any) is unobserved.
public static void WaitWithoutException(this Task task, CancellationToken cancellationToken);
}
The full API is supported on all platforms.