However, I have such approach:
private .. myDxBrush; OnRender(..) { .... heavy_calculations_block_1(); .... heavy_calculations_block_2(); .... heavy_calculations_block_3(); ... var x = myDxBrush.ToString(); } OnRenderTargetChanged() { myDxBrush.Dispose(); if (RenderTarget != null) { .... heavy_calculations_block_other(); myDxBrush = Brushes.Yellow.ToDxBrush(RenderTarget); } }
strangely, once in a while, very rarely (like 2 hours after using indicator on chart, or on faster markets), i get exception error: object reference not set to instance...
Yes, there could be an issue with other codes, but is there any chance, that while OnRender is being still executed (and the middle of action, before it reaches to `myDxBrush`), in the meantile OnRenderTargetChanged could have happened, causing to dispose or nullify that property, thus, OnRender finds that property as null.
is that possible? Should we implement `lock (smthObject)` in OnRender and OnRenderTargetChanged, to avoid such conflict?
Comment