OnStartUp { if (Bars.BarsData.ChartStyle.Pen != default(Pen)) myColorCached = Bars.BarsData.ChartStyle.Pen.Color; } OnTerminate { if (ChartControl != null && ChartControl.IsHandleCreated) { if (Bars.BarsData.ChartStyle.Pen != default(Pen) && myColorCached != default(Color)) Bars.BarsData.ChartStyle.Pen.Color = myColorCached; // Raises sporadically } }
It appears that the BarsData is being disposed while my code is running. Is there a better way to program this?
In the actual code, there are more properties being restored, and a few complete before this one throws -- those others include BarsData.ChartStyle.UpColor and DownColor. Something is being disposed while my code is running; and there is no way I can see to check if BarsData is Disposed (and even if there were, since other calls do complete before this one throws, it appears that BarsData is being disposed by another thread before the OnTerminate finishes). Perhaps someone could just confirm that this is possible. On reading this post, I will wrap only the BarsData code in a try-catch and hopefully the ChartControl is remaining valid, but the BarsData is disposing: so therefore I would not leave the chart with my modifications on it when the indicator is unloaded. Thanks in advance.
Comment