Cancellation Token as Method Parameter
When writing a method that accepts a cancellation token, the method will need to deal with a passed null token.
To do so, the method should accept the token parameter like this:
public async Task<int> DoSomething(CancellationToken ct = default(CancellationToken))
{
...
}
No Comments