Class AsyncDefer
Invokes an asynchronous action when disposed.
Implements
Inherited Members
Namespace: Recore
Assembly: Recore.dll
Syntax
public sealed class AsyncDefer : IAsyncDisposable
Remarks
Not thread-safe. Concurrent calls to dispose the object may result in the action being invoked multiple times. However, sequential calls to DisposeAsync() are idempotent. If an instance of this type is created and never disposed, the callback will not be called. By design, the callback is not called from the finalizer, which would happen non-determinstically.
Constructors
| Improve this Doc View SourceAsyncDefer(AsyncAction)
Initializes an object with an action to invoke when the object is disposed.
Declaration
public AsyncDefer(AsyncAction action)
Parameters
Type | Name | Description |
---|---|---|
AsyncAction | action |
Methods
| Improve this Doc View SourceDisposeAsync()
Invokes the callback registered with the object and marks the object as disposed.
Declaration
public ValueTask DisposeAsync()
Returns
Type | Description |
---|---|
ValueTask |