In the past we used to dispose objects (like DxBrush and etc..) in `OnStateChange->Terminated` event.
However, a while ago, NT suggested to migrate that code in `OnRenderTargetChanged`:
https://ninjatrader.com/support/help...getchanged.htm
which made the things more complicated (to destroy and recreate objects in each ORTC event.
It has been quite unflexible, because generally, a typical user, when using many Disposable resources, we create them in "DataLoaded" (or Configured) state:
..DXBrush myDX; protected override void OnStateChange() { if (State == State.Configure) { myDX = myBrush.ToDxBrush(RenderTarget); } }
But, changing that to ORTC , made coding a bit more complicated.
However, a while ago, i've found out that NinjaTrader has some hidden state, which does an excellent job.
it's State.Finalized.
So, I suggest that update that in the docs, so instead of doing this:
protected override void OnRenderTargetChanged() { if (myDX != null) { myDX.Dispose(); } if (RenderTarget != null) myDX = myBrush.ToDxBrush(RenderTarget); }
protected override void OnRenderTargetChanged() { if (State == State.Finalized) { myDX.Dispose(); } }
what about that? so, no need to re-create resources in TWICE place in code.
also, please read my other posts below, as they further reveal another problem.
Comment