I just want to make sure that my code is optimize for best performance.
I am painting lots of numbers and letters to the chart window through a loop and these objects are using different brushes.
I notice that sometimes it slows performance when I move the chart with my mouse.
Here is the structure of my code
I have all objects to be painted in a SortedDictionary and it is part of the drawing method which is called from OnRender :
foreach(KeyValuePair<int, List<string> k in dic)
{
List<string> list = k.Value as List<string>();
for(int i=0; i<list.Count; i++)
{
curElement = list[i];
// do stuff
if(xxxx)
brushColor = Brushes.Yellow
else
brushColor = Brushes.Red;
brushColorDx = brushColor.ToDxBrush(RenderTarget);
RenderTargert.DrawText(xxxxxxxxx, brushColorDx);
}
}
And OnRenderTargetChanged I have :
if(brushColorDx != null)
brushColorDx.Dispose();
I am just wondering if I manage the brushDx the right way for performance optimization.
It seems that more and more painting (shrinking the chart as much as I can ) )slows down the indicator a bit
Comment