Bugs item #2915404, was opened at 2009-12-16 04:10
Message generated for change (Comment added) made by jamcquay
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=821568&aid=2915404&group_id=161868
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: None
>Group: 0.9.10.0
>Status: Closed
>Resolution: Invalid
Priority: 5
Private: No
Submitted By: Nobody/Anonymous (nobody)
>Assigned to: Jamie McQuay (jamcquay)
Summary: .Refresh().method crashes
Initial Comment:
I'm working on a dynamic graph that shall display the value of a temperature or a level sensor in runtime.
My program is logging values into two collections. Each collection is put into the PlotSurface object's X-axis and Y-axis. This is done each second.
But I'm having trouble with the .Refresh()-method. The method causes an Argument out of range exception to be thrown. The exception's message is (translated from Swedish to English):
"Index was outside the range. It may not be negative and must be less than the crowd size. Parameter name: index"
If I debug the program with a breakpoint on the .Refresh()-method instruction and press the "step into"-button the program doesn't not crash! I can then remove the breakpoint and run the program in run-mode instead with no crashes. If I just run the program without the breakpoint, it will crash.
This is very strange and I can't understand why this is happening. I'll attach my entire Windows Form Application as a .RAR-file
----------------------------------------------------------------------
>Comment By: Jamie McQuay (jamcquay)
Date: 2009-12-16 09:10
Message:
The error in your code is that you are trying to update a UI element from a
thread that is not the UI thread (timer ticks are handled on a different
thread).
To fix this you need to handle the NPlot update in the UI thread like
this:
// Generate data samples each second
void runTimeLogger_Tick(object sender, EventArgs e)
{
xAxis.Add(counter++);
yAxis.Add((1.5 + Math.Sin((double)counter * 0.2)));
this.Invoke(new System.Windows.Forms.MethodInvoker(delegate()
{
UpdateGraph();
}));
}
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=821568&aid=2915404&group_id=161868
|