<PackageReference Include="Nito.Disposables" Version="2.5.0" />

Nito.Disposables.CollectionDisposable

Disposes a collection of disposables.
public CollectionDisposable(IDisposable[] disposables)

Creates a disposable that disposes a collection of disposables.

Creates a disposable that disposes a collection of disposables.

public static CollectionDisposable Create(IDisposable[] disposables)

Creates a disposable that disposes a collection of disposables.

public static CollectionDisposable Create(IEnumerable<IDisposable> disposables)

Creates a disposable that disposes a collection of disposables.

Makes this disposable do nothing when it is disposed. Returns the actions this disposable *would* have taken; these can be passed to a new instance to transfer ownership.

public void Add(IDisposable disposable)

Adds a disposable to the collection of disposables. If this instance is already disposed or disposing, then disposable is disposed immediately. If this method is called multiple times concurrently at the same time this instance is disposed, then the different disposable arguments may be disposed concurrently.

public bool TryAdd(IDisposable disposable)

Adds a disposable to the collection of disposables. If this instance is already disposed or disposing, then disposable is not added and this method returns false.