In unit testing a component I need to verify how a component reacts to Tasks being completed at various times.
How do I create a Task<>
that I can res
You can use a TaskCompletionSource to create a fully 'manual' task.
Represents the producer side of a Task unbound to a delegate, providing access to the consumer side through the Task property.
Hand out the the completion source's Task
property to the consumer, and call SetResult
on it (at will) to complete the task. Note that you also have SetCanceled
and SetException
to represent cancellations and failures, respectively.