Class TaskExtensions
Provides additional methods for working with tasks.
Inherited Members
Namespace: Recore.Threading.Tasks
Assembly: Recore.dll
Syntax
public static class TaskExtensions
Methods
| Improve this Doc View SourceSynchronize(Task)
Blocks the current thread until the task completes.
Declaration
public static void Synchronize(this Task task)
Parameters
| Type | Name | Description |
|---|---|---|
| Task | task |
Remarks
If task is terminated by an exception, that exception
will be rethrown in the current context.
Unlike Wait(), that exception will be of its original type,
not AggregateException.
It will also preserve its original stack trace.
This exception-throwing behavior is the same as if you had used await.
Note that it is still possible to deadlock with this method.
See https://blog.stephencleary.com/2014/12/a-tour-of-task-part-6-results.html.
Synchronize<T>(Task<T>)
Blocks the current thread until the task completes.
Declaration
public static T Synchronize<T>(this Task<T> task)
Parameters
| Type | Name | Description |
|---|---|---|
| Task<T> | task |
Returns
| Type | Description |
|---|---|
| T |
Type Parameters
| Name | Description |
|---|---|
| T |
Remarks
If task is terminated by an exception, that exception
will be rethrown in the current context.
Unlike Result, that exception will be of its original type,
not AggregateException.
It will also preserve its original stack trace.
This exception-throwing behavior is the same as if you had used await.
Note that it is still possible to deadlock with this method.
See https://blog.stephencleary.com/2014/12/a-tour-of-task-part-6-results.html.