2using System.Threading.Tasks;
15 protected readonly TaskCompletionSource<ReturnType>
task;
25 this.task =
new TaskCompletionSource<ReturnType>();
26 this.callback = Callback;
36 this.task.TrySetResult(this.callback());
40 this.task.TrySetException(ex);
48 public Task<ReturnType>
WaitAsync() => this.task.Task;
Task with zero arguments to be synchronized.
Task< ReturnType > WaitAsync()
Waits for the task to complete.
void Execute()
Executes the task.
SyncTask0(Callback0< ReturnType > Callback)
Task to be synchronized.
readonly TaskCompletionSource< ReturnType > task
Task completion source, waiting for the result of the task.
Interface for tasks to be synckronized.
delegate ReturnType Callback0< ReturnType >()
Delegate to methods of zero parameters and a given return type.