7 [__DynamicallyInvokable]
8 [HostProtection(
SecurityAction.LinkDemand, Synchronization =
true, ExternalThreading =
true)]
11 private readonly CancellationCallbackInfo m_callbackInfo;
13 private readonly SparselyPopulatedArrayAddInfo<CancellationCallbackInfo> m_registrationInfo;
15 internal CancellationTokenRegistration(CancellationCallbackInfo callbackInfo, SparselyPopulatedArrayAddInfo<CancellationCallbackInfo> registrationInfo)
17 m_callbackInfo = callbackInfo;
18 m_registrationInfo = registrationInfo;
22 internal bool TryDeregister()
24 if (m_registrationInfo.Source ==
null)
28 CancellationCallbackInfo cancellationCallbackInfo = m_registrationInfo.Source.SafeAtomicRemove(m_registrationInfo.Index, m_callbackInfo);
29 if (cancellationCallbackInfo != m_callbackInfo)
37 [__DynamicallyInvokable]
40 bool flag = TryDeregister();
41 CancellationCallbackInfo callbackInfo = m_callbackInfo;
42 if (callbackInfo !=
null)
47 cancellationTokenSource.WaitForCallbackToComplete(m_callbackInfo);
56 [__DynamicallyInvokable]
66 [__DynamicallyInvokable]
69 return !left.
Equals(right);
75 [__DynamicallyInvokable]
76 public override bool Equals(
object obj)
88 [__DynamicallyInvokable]
91 if (m_callbackInfo == other.m_callbackInfo && m_registrationInfo.Source == other.m_registrationInfo.Source)
93 return m_registrationInfo.Index == other.m_registrationInfo.Index;
100 [__DynamicallyInvokable]
103 if (m_registrationInfo.Source !=
null)
105 return m_registrationInfo.Source.GetHashCode() ^ m_registrationInfo.Index.GetHashCode();
107 return m_registrationInfo.Index.GetHashCode();
static Thread CurrentThread
Gets the currently running thread.
static bool operator==(CancellationTokenRegistration left, CancellationTokenRegistration right)
Determines whether two T:System.Threading.CancellationTokenRegistration instances are equal.
Provides a mechanism for releasing unmanaged resources.To browse the .NET Framework source code for t...
override int GetHashCode()
Serves as a hash function for a T:System.Threading.CancellationTokenRegistration.
Represents a callback delegate that has been registered with a T:System.Threading....
SecurityAction
Specifies the security actions that can be performed using declarative security.
static bool operator !=(CancellationTokenRegistration left, CancellationTokenRegistration right)
Determines whether two T:System.Threading.CancellationTokenRegistration instances are not equal.
override bool Equals(object obj)
Determines whether the current T:System.Threading.CancellationTokenRegistration instance is equal to ...
CancellationTokenSource()
Initializes a new instance of the T:System.Threading.CancellationTokenSource class.
int ManagedThreadId
Gets a unique identifier for the current managed thread.
Defines a generalized method that a value type or class implements to create a type-specific method f...
Signals to a T:System.Threading.CancellationToken that it should be canceled.
bool Equals(CancellationTokenRegistration other)
Determines whether the current T:System.Threading.CancellationTokenRegistration instance is equal to ...
bool IsCancellationRequested
Gets whether cancellation has been requested for this T:System.Threading.CancellationTokenSource.
void Dispose()
Releases all resources used by the current instance of the T:System.Threading.CancellationTokenRegist...
Creates and controls a thread, sets its priority, and gets its status.