For your async API’s it is a general good practice to allow to pass a CancellationToken parameter. This parameter allows you to check if a cancellation is requested and to handle this properly.
Tip: If you want to learn everything about the correct way to use CancellationTokens and handle cancellation in your code, check out the great blog series about this topic from Stephen Cleary.
While reviewing some code, I noticed an API where I forgot to add the CancellationToken parameter, so I updated the code like this:
The compiler didn’t like this and complained with the following error message:
Starting from C# 7.1, you can easily solve this by using the default literal: