Skip to content

CompositeDisposableAsync class

Defined in

Namespace: ReactiveUI.Extensions.Async.Disposables Assembly: ReactiveUI.Extensions.dll Full name: ReactiveUI.Extensions.Async.Disposables.CompositeDisposableAsync Modifiers: public sealed

Summary

View source

        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

NameSummary
.ctorInitializes a new instance of the [CompositeDisposableAsync](# class. The backing array is allocated lazily on the first...

Properties

NameSummary
IsDisposedGets a value indicating whether the object has been disposed.
CountGets the number of elements contained in the collection.

Methods

NameSummary
AddAsyncAdds an asynchronous disposable item to the collection, or disposes it immediately if the collection has already been disposed.
RemoveRemoves the specified item from the collection and disposes it asynchronously.
ClearAsynchronously disposes all items in the collection and removes them.
ContainsDetermines whether the collection contains the specified asynchronous disposable item.
CopyToCopies the elements of the collection to the specified array, starting at the given array index.
DisposeAsyncAsynchronously releases all resources used by the collection and disposes of each contained asynchronous disposable object.
GetEnumeratorReturns 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.
Inherited members