CompositeDisposableAsync class¶
Defined in
Namespace: ReactiveUI.Extensions.Async.Disposables
Assembly: ReactiveUI.Extensions.dll
Full name: ReactiveUI.Extensions.Async.Disposables.CompositeDisposableAsync
Modifiers: public sealed
Summary¶
Represents a thread-safe collection of asynchronous disposable objects that are disposed together as a group.
Provides methods to add, remove, and asynchronously dispose contained resources as a single operation.
Applies to
net10.0, net10.0-browserwasm1.0, net10.0-desktop1.0, net9.0, net9.0-browserwasm1.0, net9.0-desktop1.0, net8.0, net8.0-ios17.5, net8.0-maccatalyst17.5, net8.0-macos14.2, net8.0-macos14.5, net8.0-tvos17.2, netstandard2.1, net462, net481
Class hierarchy
classDiagram
class CompositeDisposableAsync
class IAsyncDisposable {
<>
}
IAsyncDisposable <|.. CompositeDisposableAsync
Implements: IAsyncDisposable
Remarks¶
Use this class to manage the lifetime of multiple IAsyncDisposable resources, ensuring that all are disposed when the collection is disposed. Once disposed, the collection cannot be used to add or remove items. This class is not read-only and is safe for concurrent access from multiple threads.
Constructors¶
| Name | Summary |
|---|---|
| .ctor | Initializes a new instance of the [CompositeDisposableAsync](# class. The backing array is allocated lazily on the first... |
Properties¶
| Name | Summary |
|---|---|
| IsDisposed | Gets a value indicating whether the object has been disposed. |
| Count | Gets the number of elements contained in the collection. |
Methods¶
| Name | Summary |
|---|---|
| AddAsync | Adds an asynchronous disposable item to the collection, or disposes it immediately if the collection has already been disposed. |
| Remove | Removes the specified item from the collection and disposes it asynchronously. |
| Clear | Asynchronously disposes all items in the collection and removes them. |
| Contains | Determines whether the collection contains the specified asynchronous disposable item. |
| CopyTo | Copies the elements of the collection to the specified array, starting at the given array index. |
| DisposeAsync | Asynchronously releases all resources used by the collection and disposes of each contained asynchronous disposable object. |
| GetEnumerator | Returns an enumerator that iterates a snapshot of the non-null disposables in the collection. The snapshot is taken under the gate; subsequent mutations do not affect the enumerator. |