Click or drag to resize
AB4D logo

DXResourcesTracker Class

DXResourcesTracker collects classes that implement IDXResource and can report all colleced classes. Objects are collected with WeakReference.
Inheritance Hierarchy
SystemObject
  Ab3d.DirectXDXResourcesTracker

Namespace: Ab3d.DirectX
Assembly: Ab3d.DXEngine (in Ab3d.DXEngine.dll) Version: 7.0.8865.1045
Syntax
C#
public class DXResourcesTracker

The DXResourcesTracker type exposes the following members.

Constructors
 NameDescription
Public methodDXResourcesTrackerInitializes a new instance of the DXResourcesTracker class
Top
Properties
 NameDescription
Public propertyIsTrackingResources Gets a boolean that specifies if tracking resources is enabled.
Top
Methods
 NameDescription
Public methodAddResource Add IDXResource to the list of tracked resources.
Public methodDumpTrackedResources Writes formatted string with tracked resources with the System.Diagnostics.Debug.WriteLine.
Public methodGetTrackedResources Gets a list of IDXResources objects that were tracked while tracking was enabled and are still alive (garbage collector did not disposed them yet).
Public methodGetTrackedResourcesReport Gets a formatted string with tracked resources.
Public methodStartTrackingResources Starts tracking of resources.
Public methodStopTrackingResources Stop tracking resources.
Top
Remarks

DXResourcesTracker collects classes that implement IDXResource and can report all colleced classes.

It is used as a static ResourcesTracker property in DXResourceBase class. If tracking is enabled, this static instance tracks all the objects that derive from DXResourceBase. Objects that derive from SharedDXResource or SharedDXResourceWrapperT are also tracked.

Resources tracking collects all the components in a WeakReference list. It is possible to get collection of all resources that were collected - their ids, object type, name, etc.

To enable components tracking call the StartTrackingResources method - for example:
Ab3d.DirectX.DXResourceBase.ResourcesTracker.StartTrackingResources();

After the resources have been tracked, it is possible to get tracked resources by GetTrackedResources, GetTrackedResourcesReport(Boolean) or display the tracked resources in Visual Studio's Immediate Window with DumpTrackedResources(Boolean).

To track all resources this method must be called before any other object is created (for example before InitializeComponent in the application's main window).

It is possible to stop tracking resources with StopTrackingResources.

If you want to track your objects that implement IDXResource interface but are not derived from DXResourceBase, SharedDXResource or SharedDXResourceWrapperT, than all you need to do to get your object tracked is to call the AddResource(IDXResource) method on the static ResourcesTracker property. If you would also like to get the object Id, you can also call GetNextId method and pass your object as parameter - when resource tracking is enabled your object will be also tracked.

See Also