2019-08-23 11:56:54 -07:00
|
|
|
// This file contains portions of code released by Microsoft under the MIT license as part
|
|
|
|
// of an open-sourcing initiative in 2014 of the C# core libraries.
|
|
|
|
// The original source was submitted to https://github.com/Microsoft/referencesource
|
|
|
|
|
|
|
|
namespace System.Threading
|
|
|
|
{
|
|
|
|
class CancellationTokenSource
|
|
|
|
{
|
|
|
|
private const int CANNOT_BE_CANCELED = 0;
|
|
|
|
private const int NOT_CANCELED = 1;
|
|
|
|
private const int NOTIFYING = 2;
|
|
|
|
private const int NOTIFYINGCOMPLETE = 3;
|
|
|
|
|
|
|
|
private volatile int m_state;
|
|
|
|
|
|
|
|
public bool IsCancellationRequested
|
|
|
|
{
|
|
|
|
get { return m_state >= NOTIFYING; }
|
|
|
|
}
|
|
|
|
|
2020-03-09 06:34:16 -07:00
|
|
|
bool CanBeCanceled
|
2019-08-23 11:56:54 -07:00
|
|
|
{
|
|
|
|
get { return m_state != CANNOT_BE_CANCELED; }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|