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))
{
  ...
}

 


Revision #1
Created 9 July 2025 06:15:05 by glwhite
Updated 9 July 2025 06:31:52 by glwhite