Is the BrushDX properly disposed?
Since the Stroke has properties that are IDisposable, why is the Stroke itself not IDisposable?
Everywhere I look I see code such as the example below that does not bother with proper cleanup and disposal of the BrushDX property of the Stroke class.
The code below is similar to many of these examples.
// Here's an indicator property stroke initialized to blue. public Stroke MyStroke { get; set; } = new Stroke(Brushes.Blue); public override void OnRenderTargetChanged() { if (RenderTarget is null) return; MyStroke.RenderTarget = RenderTarget; // automatically creates the BrushDX property of the stroke. } protected override void ToughOnRender(ChartControl chartControl, ChartScale chartScale) { // use MyStroke.BrushDX somehow }
I would have expected the following code also to be necessary.
override OnStateChanged() { if (State == State.Terminated) { MyStroke?.BrushDX?.Dispose(); // or even better would be: // MyStroke?.Dispose(); } }
OR, is the BrushDX property value recreated EVERY TIME the property is accessed, and are we expected to dispose the value returned every time we access it?
Also, does the Stroke object dispose old BrushDX objects when its RenderTarget property is updated?
Comment