Search Results for

    Show / Hide Table of Contents

    Class CompositeDisposable

    Represents a group of disposable resources that are disposed together.

    Inheritance
    Object
    CompositeDisposable
    Implements
    ICollection<IDisposable>
    IEnumerable<IDisposable>
    IEnumerable
    ICancelable
    IDisposable
    Inherited Members
    Object.Equals(Object)
    Object.Equals(Object, Object)
    Object.GetHashCode()
    Object.GetType()
    Object.MemberwiseClone()
    Object.ToString()
    Object.ReferenceEquals(Object, Object)
    Namespace: System.Reactive.Disposables
    Assembly: System.Reactive.Core.dll
    Syntax
    public sealed class CompositeDisposable : ICollection<IDisposable>, IEnumerable<IDisposable>, IEnumerable, ICancelable, IDisposable

    Constructors

    | Improve this Doc View Source

    CompositeDisposable()

    Initializes a new instance of the CompositeDisposable class with no disposables contained by it initially.

    Declaration
    public CompositeDisposable()
    | Improve this Doc View Source

    CompositeDisposable(IEnumerable<IDisposable>)

    Initializes a new instance of the CompositeDisposable class from a group of disposables.

    Declaration
    public CompositeDisposable(IEnumerable<IDisposable> disposables)
    Parameters
    Type Name Description
    IEnumerable<IDisposable> disposables

    Disposables that will be disposed together.

    Exceptions
    Type Condition
    ArgumentNullException

    disposables is null.

    | Improve this Doc View Source

    CompositeDisposable(IDisposable[])

    Initializes a new instance of the CompositeDisposable class from a group of disposables.

    Declaration
    public CompositeDisposable(params IDisposable[] disposables)
    Parameters
    Type Name Description
    IDisposable[] disposables

    Disposables that will be disposed together.

    Exceptions
    Type Condition
    ArgumentNullException

    disposables is null.

    | Improve this Doc View Source

    CompositeDisposable(Int32)

    Initializes a new instance of the CompositeDisposable class with the specified number of disposables.

    Declaration
    public CompositeDisposable(int capacity)
    Parameters
    Type Name Description
    Int32 capacity

    The number of disposables that the new CompositeDisposable can initially store.

    Exceptions
    Type Condition
    ArgumentOutOfRangeException

    capacity is less than zero.

    Properties

    | Improve this Doc View Source

    Count

    Gets the number of disposables contained in the CompositeDisposable.

    Declaration
    public int Count { get; }
    Property Value
    Type Description
    Int32
    | Improve this Doc View Source

    IsDisposed

    Gets a value that indicates whether the object is disposed.

    Declaration
    public bool IsDisposed { get; }
    Property Value
    Type Description
    Boolean
    | Improve this Doc View Source

    IsReadOnly

    Always returns false.

    Declaration
    public bool IsReadOnly { get; }
    Property Value
    Type Description
    Boolean

    Methods

    | Improve this Doc View Source

    Add(IDisposable)

    Adds a disposable to the CompositeDisposable or disposes the disposable if the CompositeDisposable is disposed.

    Declaration
    public void Add(IDisposable item)
    Parameters
    Type Name Description
    IDisposable item

    Disposable to add.

    Exceptions
    Type Condition
    ArgumentNullException

    item is null.

    | Improve this Doc View Source

    Clear()

    Removes and disposes all disposables from the CompositeDisposable, but does not dispose the CompositeDisposable.

    Declaration
    public void Clear()
    | Improve this Doc View Source

    Contains(IDisposable)

    Determines whether the CompositeDisposable contains a specific disposable.

    Declaration
    public bool Contains(IDisposable item)
    Parameters
    Type Name Description
    IDisposable item

    Disposable to search for.

    Returns
    Type Description
    Boolean

    true if the disposable was found; otherwise, false.

    Exceptions
    Type Condition
    ArgumentNullException

    item is null.

    | Improve this Doc View Source

    CopyTo(IDisposable[], Int32)

    Copies the disposables contained in the CompositeDisposable to an array, starting at a particular array index.

    Declaration
    public void CopyTo(IDisposable[] array, int arrayIndex)
    Parameters
    Type Name Description
    IDisposable[] array

    Array to copy the contained disposables to.

    Int32 arrayIndex

    Target index at which to copy the first disposable of the group.

    Exceptions
    Type Condition
    ArgumentNullException

    array is null.

    ArgumentOutOfRangeException

    arrayIndex is less than zero. -or - arrayIndex is larger than or equal to the array length.

    | Improve this Doc View Source

    Dispose()

    Disposes all disposables in the group and removes them from the group.

    Declaration
    public void Dispose()
    | Improve this Doc View Source

    GetEnumerator()

    Returns an enumerator that iterates through the CompositeDisposable.

    Declaration
    public IEnumerator<IDisposable> GetEnumerator()
    Returns
    Type Description
    IEnumerator<IDisposable>

    An enumerator to iterate over the disposables.

    | Improve this Doc View Source

    Remove(IDisposable)

    Removes and disposes the first occurrence of a disposable from the CompositeDisposable.

    Declaration
    public bool Remove(IDisposable item)
    Parameters
    Type Name Description
    IDisposable item

    Disposable to remove.

    Returns
    Type Description
    Boolean

    true if found; false otherwise.

    Exceptions
    Type Condition
    ArgumentNullException

    item is null.

    Explicit Interface Implementations

    | Improve this Doc View Source

    IEnumerable.GetEnumerator()

    Returns an enumerator that iterates through the CompositeDisposable.

    Declaration
    IEnumerator IEnumerable.GetEnumerator()
    Returns
    Type Description
    IEnumerator

    An enumerator to iterate over the disposables.

    Implements

    System.Collections.Generic.ICollection<T>
    System.Collections.Generic.IEnumerable<T>
    System.Collections.IEnumerable
    ICancelable
    System.IDisposable

    Extension Methods

    Observable.Subscribe<TSource>(IEnumerable<TSource>, IObserver<TSource>)
    Observable.Subscribe<TSource>(IEnumerable<TSource>, IObserver<TSource>, IScheduler)
    Observable.ToObservable<TSource>(IEnumerable<TSource>)
    Observable.ToObservable<TSource>(IEnumerable<TSource>, IScheduler)
    • Improve this Doc
    • View Source
    In This Article
    Back to top Generated by DocFX