CancellationToken.UnsafeRegister Method
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.
Overloads
UnsafeRegister(Action<Object,CancellationToken>, Object) |
Registers a delegate that will be called when this CancellationToken is canceled. |
UnsafeRegister(Action<Object>, Object) |
Registers a delegate that is called when this CancellationToken is canceled. |
UnsafeRegister(Action<Object,CancellationToken>, Object)
- Source:
- CancellationToken.cs
- Source:
- CancellationToken.cs
- Source:
- CancellationToken.cs
Registers a delegate that will be called when this CancellationToken is canceled.
public:
System::Threading::CancellationTokenRegistration UnsafeRegister(Action<System::Object ^, System::Threading::CancellationToken> ^ callback, System::Object ^ state);
public System.Threading.CancellationTokenRegistration UnsafeRegister (Action<object?,System.Threading.CancellationToken> callback, object? state);
member this.UnsafeRegister : Action<obj, System.Threading.CancellationToken> * obj -> System.Threading.CancellationTokenRegistration
Public Function UnsafeRegister (callback As Action(Of Object, CancellationToken), state As Object) As CancellationTokenRegistration
Parameters
- callback
- Action<Object,CancellationToken>
The delegate to be executed when the CancellationToken is canceled.
- state
- Object
The state to pass to the callback
when the delegate is invoked. This may be null
.
Returns
The CancellationTokenRegistration instance that can be used to unregister the callback.
Exceptions
callback
is null
.
Remarks
If this token is already in the canceled state, the delegate will be run immediately and synchronously. Any exception the delegate generates is propagated out of this method call. ExecutionContext is not captured or flowed to the callback's invocation.
Applies to
UnsafeRegister(Action<Object>, Object)
- Source:
- CancellationToken.cs
- Source:
- CancellationToken.cs
- Source:
- CancellationToken.cs
Registers a delegate that is called when this CancellationToken is canceled.
public:
System::Threading::CancellationTokenRegistration UnsafeRegister(Action<System::Object ^> ^ callback, System::Object ^ state);
public System.Threading.CancellationTokenRegistration UnsafeRegister (Action<object?> callback, object? state);
member this.UnsafeRegister : Action<obj> * obj -> System.Threading.CancellationTokenRegistration
Public Function UnsafeRegister (callback As Action(Of Object), state As Object) As CancellationTokenRegistration
Parameters
The delegate to execute when the CancellationToken is canceled.
- state
- Object
The state to pass to the callback
when the delegate is invoked. This may be null
.
Returns
An object that can be used to unregister the callback.
Exceptions
callback
is null.
Remarks
If this token is already in the canceled state, the delegate is run immediately and synchronously. Any exception the delegate generates is propagated out of this method call.
The ExecutionContext is not captured or flowed to the callback's invocation.
Applies to
.NET
피드백
https://aka.ms/ContentUserFeedback
출시 예정: 2024년 내내 콘텐츠에 대한 피드백 메커니즘으로 GitHub 문제를 단계적으로 폐지하고 이를 새로운 피드백 시스템으로 바꿀 예정입니다. 자세한 내용은 다음을 참조하세요.다음에 대한 사용자 의견 제출 및 보기