ObjectCollector Struct
Namespace: Stride.CoreAssembly: 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.. |
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. |
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 |