Stride

OPEN / CLOSE
  • Features
  • Blog
  • Documentation
  • Community
(icon) Download

  • Discord
  • Facebook
  • Twitter
  • YouTube

LANGUAGE

OPEN / CLOSE
  • English
  • 日本語
    Show / Hide Table of Contents

    ObjectCollector Struct

    Namespace: Stride.Core
    Assembly: Stride.Core.dll

    A struct to dispose System.IDisposable, IReferencable instances and allocated unmanaged memory.

    public struct ObjectCollector : IDisposable
    Name Description
    Properties
    Count

    Gets the number of elements to dispose.

    Methods
    Add<T>(T)

    Adds a System.IDisposable object or a System.IntPtr allocated using AllocateMemory(Int32, Int32) to the list of the objects to dispose.

    Dispose()

    Disposes all object collected by this class and clear the list. The collector can still be used for collecting.

    EnsureValid()
    Remove<T>(T)

    Removes a disposable object to the list of the objects to dispose.

    RemoveAndDispose<T>(ref T)

    Dispose a disposable object and set the reference to null. Removes this object from this instance..

    | Improve this Doc View Source

    Properties


    Count

    Gets the number of elements to dispose.

    public readonly int Count { get; }
    Property Value
    Type Description
    System.Int32

    The number of elements to dispose.

    | Improve this Doc View Source

    Methods


    Add<T>(T)

    Adds a System.IDisposable object or a System.IntPtr allocated using AllocateMemory(Int32, Int32) to the list of the objects to dispose.

    public T Add<T>(T objectToDispose)
    Parameters
    Type Name Description
    T objectToDispose

    To dispose.

    Returns
    Type Description
    T
    Type Parameters
    Name Description
    T
    Exceptions
    Type Condition
    System.ArgumentException

    If objectToDispose argument is not IDisposable or a valid memory pointer allocated by AllocateMemory(Int32, Int32)


    Dispose()

    Disposes all object collected by this class and clear the list. The collector can still be used for collecting.

    public void Dispose()
    Remarks

    To completely dispose this instance and avoid further dispose, use Dispose() method instead.


    EnsureValid()

    public void EnsureValid()

    Remove<T>(T)

    Removes a disposable object to the list of the objects to dispose.

    public void Remove<T>(T objectToDispose)
    Parameters
    Type Name Description
    T objectToDispose

    To dispose.

    Type Parameters
    Name Description
    T

    RemoveAndDispose<T>(ref T)

    Dispose a disposable object and set the reference to null. Removes this object from this instance..

    public void RemoveAndDispose<T>(ref T objectToDispose)
    Parameters
    Type Name Description
    T objectToDispose

    Object to dispose.

    Type Parameters
    Name Description
    T

    Inherited Members

    System.ValueType.Equals(System.Object)
    System.ValueType.GetHashCode()
    System.ValueType.ToString()

    Extension Methods

    ComponentBaseExtensions.DisposeBy<T>(T, ICollectorHolder)
    ComponentBaseExtensions.RemoveDisposeBy<T>(T, ICollectorHolder)
    • Improve this Doc
    • View Source
    In This Article

    Back to top

    Copyright © 2019-2021 .NET Foundation and Contributors
    Supported by the .NET Foundation