2using System.Threading.Tasks;
11 private readonly TaskCompletionSource<bool> processed =
new TaskCompletionSource<bool>();
18 return this.
Execute(CancellationToken.None);
25 public abstract Task
Execute(CancellationToken Cancel);
33 this.processed.TrySetResult(Result);
42 return this.processed.Task;
50 public Task<bool>
Wait(CancellationToken Cancel)
52 if (Cancel.CanBeCanceled)
53 Cancel.Register(() => this.processed.TrySetResult(
false));
55 return this.processed.Task;
Represents an asynchronous operation to be performed.
abstract Task Execute(CancellationToken Cancel)
Executes the operation.
Task< bool > Wait(CancellationToken Cancel)
Waits for the item to be processed.
Task Execute()
Executes the operation.
Task< bool > Wait()
Waits for the item to be processed.
void Processed(bool Result)
Flags the item as processed.
Interface for asynchronous operations.