you create a variable here and use it only once
bool taskExecutionCancelled = IsScripteExecutionCancelled(); if (taskExecutionCancelled) { tokenSource.Cancel(); }
I would just use the method in the if statement, like
if (IsScripteExecutionCancelled())
{
tokenSource.Cancel();
}
if you were going to use this value somewhere else and didn't want it evaluated again, then you could assign it to a variable, but then you need to keep in mind that calling the methodvariable will not run the method every time that variable is called.