CancellationTokenSource represents a logical operation that can be canceled. The Token property of CancellationTokenSource provides the token object that provides the part of the logical operation.
Whenever the Cancel() method gets called on the CancellationTokenSource object, all distributed tokens from that source get their IsCancellationRequested property set as true.
In our example, the for loop inside our CalculateOddEven method polls the IsCancellationRequested property and fills the totalOdd and totalEven member variables with -1, which can be used to understand that a cancellation call was performed. Based on that value, the Operation canceled! message gets displayed on the screen.