Class SingleAssignmentDisposableAsync
- Namespace
- ReactiveUI.Extensions.Async.Disposables
- Assembly
- ReactiveUI.Extensions.dll
Represents an asynchronously disposable resource that allows a single assignment of its underlying disposable. Once disposed, further assignments will dispose the assigned resource immediately.
public sealed class SingleAssignmentDisposableAsync : IAsyncDisposable
- Inheritance
-
SingleAssignmentDisposableAsync
- Implements
- Extension Methods
Remarks
This type is useful for scenarios where an asynchronous disposable resource must be assigned exactly once, and where disposal may occur before or after the assignment. If disposed before assignment, any subsequently assigned resource will be disposed immediately. This class is not thread-safe for concurrent assignment and disposal; external synchronization is required if used from multiple threads.
Constructors
SingleAssignmentDisposableAsync()
public SingleAssignmentDisposableAsync()
Properties
IsDisposed
Gets a value indicating whether the object has been disposed.
public bool IsDisposed { get; }
Property Value
Methods
DisposeAsync()
Asynchronously releases the unmanaged resources used by the object.
public ValueTask DisposeAsync()
Returns
- ValueTask
A ValueTask that represents the asynchronous dispose operation.
GetDisposable()
Gets the current asynchronous disposable resource, or an empty disposable if the resource has already been disposed.
public IAsyncDisposable? GetDisposable()
Returns
- IAsyncDisposable
An IAsyncDisposable representing the current resource, or Empty if the resource has been disposed. Returns null if no resource is set.
SetDisposableAsync(IAsyncDisposable?)
Asynchronously sets the current disposable resource to the specified value, replacing any previously set resource.
public ValueTask SetDisposableAsync(IAsyncDisposable? value)
Parameters
valueIAsyncDisposableThe new IAsyncDisposable instance to set as the current resource, or null to clear the current resource.