CancellationTokenRegistration Struct
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Represents a callback delegate that has been registered with a CancellationToken.
public value class CancellationTokenRegistration : IDisposable, IEquatable<System::Threading::CancellationTokenRegistration>
public value class CancellationTokenRegistration : IAsyncDisposable, IDisposable, IEquatable<System::Threading::CancellationTokenRegistration>
public struct CancellationTokenRegistration : IDisposable, IEquatable<System.Threading.CancellationTokenRegistration>
public readonly struct CancellationTokenRegistration : IAsyncDisposable, IDisposable, IEquatable<System.Threading.CancellationTokenRegistration>
public readonly struct CancellationTokenRegistration : IDisposable, IEquatable<System.Threading.CancellationTokenRegistration>
type CancellationTokenRegistration = struct
interface IDisposable
type CancellationTokenRegistration = struct
interface IAsyncDisposable
interface IDisposable
Public Structure CancellationTokenRegistration
Implements IDisposable, IEquatable(Of CancellationTokenRegistration)
Public Structure CancellationTokenRegistration
Implements IAsyncDisposable, IDisposable, IEquatable(Of CancellationTokenRegistration)
- Inheritance
- Implements
Remarks
The callback is called when the token is canceled. To unregister a callback, dispose the corresponding Registration instance. For more information and code examples see Cancellation in Managed Threads.
Properties
Token |
Gets the CancellationToken with which this registration is associated. |
Methods
Dispose() |
Disposes of the registration and unregisters the target callback from the associated CancellationToken. |
DisposeAsync() |
Disposes of the registration and unregisters the target callback from the associated CancellationToken. |
Equals(CancellationTokenRegistration) |
Determines whether the current CancellationTokenRegistration instance is equal to the specified CancellationTokenRegistration. |
Equals(Object) |
Determines whether the current CancellationTokenRegistration instance is equal to the specified CancellationTokenRegistration. |
GetHashCode() |
Serves as a hash function for a CancellationTokenRegistration. |
Unregister() |
Disposes of the registration and unregisters the target callback from the associated CancellationToken. |
Operators
Equality(CancellationTokenRegistration, CancellationTokenRegistration) |
Determines whether two CancellationTokenRegistration instances are equal. |
Inequality(CancellationTokenRegistration, CancellationTokenRegistration) |
Determines whether two CancellationTokenRegistration instances are not equal. |
Extension Methods
ConfigureAwait(IAsyncDisposable, Boolean) |
Configures how awaits on the tasks returned from an async disposable are performed. |
Applies to
Thread Safety
All public and protected members of CancellationTokenRegistration are thread-safe and may be used concurrently from multiple threads, with the exception of Dispose, which must only be used when all other operations on the CancellationTokenRegistration have completed.
See also
反馈
https://aka.ms/ContentUserFeedback。
即将发布:在整个 2024 年,我们将逐步淘汰作为内容反馈机制的“GitHub 问题”,并将其取代为新的反馈系统。 有关详细信息,请参阅:提交和查看相关反馈