First, sorry for my bad english.
I have to draw a curve almost in real time. To do that I use: - a Thread to stack points - a thread to unstack points - and the "graphic thread" which is kind of blackbox to me, and that i just can reach it by the window Dispatcher with Invoke methode.
When i log time between start and end of the call to Dispatcher.Invoke, i see a lead time from 3 to 110ms. And between start and end of the effective drawing methode i see lead time from 3 to 55ms ?!!? I cant understand how i can waste so much time, why do i got so random timing, and more over how can i make this quick and straigh.(like i use a stack, with these huge timing the stack overflow often, crashing application :S)
UnStack thread loop:
while (exRunningFlag)
{
lock (myLock)
{
while ( stackingListPoint.Count > 0)
{
LOG
this.Dispatcher.Invoke(new Action(() =>
{
LOG
graph.AddPoint(this.stackingListPoint.Dequeue());
LOG
}), System.Windows.Threading.DispatcherPriority.Send);
LOG
}
}
}
Thread.Sleep(3);
}
public void AddPoint(System.Windows.Point pt)//Data
{
int resNeedResize = needResize(pt);
// ------ rare case, only when need to redraw all curves. This is not relative to my weird delay
if (resNeedResize != 0)
{
ReDraw(resNeedResize);
return;
}
// ----
currentPt = ConversionDataPtToGraphPt(pt);
if ((lastPt.X != -1) && (lastPt.Y != -1))
{
g = CreateGraphics();
g.DrawLine(pen_Courbe, lastPt, currentPt);
g.Flush();
}
lastPt = currentPt;
ListPointCollection.Last().Add(pt);
}
Thanks for any help u can bring to me, or if u saw that I missed something revelant:S.
PS: Sorry to people who already saw that post in french :p