I have some async code that I would like to add a CancellationToken
to. However, there are many implementations where this is not needed so I would like to have a d
Tofutim's answer is one way, but from the comments I see that people have issues with it.
In that case, I did suggest that one can have a method as follows:
Task DoStuff(...., CancellationToken ct)
{
}
and overload it as:
Task DoStuff(....)
{
return DoStuff(...., CancellationToken.None);
}
This compiles, because the value of CancellationToken.None
is not required at compile time.