I often see the following code which is the first view looks good since one is used to check a precondition before doing something else.
But when one reads the name of the method it feels like the preceding if statement already is included in the method itself. So is there any reason to write the code like it is in this example or could one just skip the if-statement and run ThrowIfCancellationRequested directly.
Of course its a different thing if one need to cleanup before exiting then I fully understand the use of the if-statement.
if (cancellationToken.IsCancellationRequested)
{
cancellationToken.ThrowIfCancellationRequested();
}