Using `Task.WhenAll` with `INotifyCompletion`

Viewed 133

I have a custom operation, which implements the GetAwaiter method, which returns a custom object which implements INotifyCompletion.

Task.WhenAll only support instances of Task. Is there any way to wrap a task around a INotifyCompletion?

Edit: The reason is I want to await multiple of them.

1 Answers

Answering my own question. I solved it by adding the following method to my class, which has the GetAwaiter method.

public async Task GetTask() {
    await this;
}

Then I can call Task.WhenAll(myCustomAwaitableObject.GetTask()).

Related