DXResources |
public class DXResourcesTracker
The DXResourcesTracker type exposes the following members.
Name | Description | |
---|---|---|
DXResourcesTracker | Initializes a new instance of the DXResourcesTracker class |
Name | Description | |
---|---|---|
IsTrackingResources | Gets a boolean that specifies if tracking resources is enabled. |
Name | Description | |
---|---|---|
AddResource | Add IDXResource to the list of tracked resources. | |
DumpTrackedResources | Writes formatted string with tracked resources with the System.Diagnostics.Debug.WriteLine. | |
GetTrackedResources | Gets a list of IDXResources objects that were tracked while tracking was enabled and are still alive (garbage collector did not disposed them yet). | |
GetTrackedResourcesReport | Gets a formatted string with tracked resources. | |
StartTrackingResources | Starts tracking of resources. | |
StopTrackingResources | Stop tracking resources. |
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.