Awaitable
This lesson explains the awaitable concept in C#
We'll cover the following...
Awaitable
In our previous example, we have used the await
operator with objects of type Task
. What types are allowed to be used with the await
operator? The requirements are as follows:
The type should have a method
GetAwaiter()
that returns an instance of a class satisfying specific properties. Say if the return type is classX
then it must meet the following bullet points.X
must implement the interfaceINotifyCompletion
and optionally theICriticalNotifyCompletion
interface.X
must have an accessible, readable instance propertyIsCompleted
of typebool
.X
must have an accessible instance methodGetResult()
with no parameters and no type parameters.
A type which satisfies the ...