Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

waveformgraph uses all CPU and crash

Hi,

 

I have two problems with the WaveFormGraph in a visual studio 2005 application:

 

I have a data acquisition system which reads data from transmitters and then plot data in several WaveFormGraph (one for each transmitter). Each graph has a thread and is in a separated window.

The problem is that each WaveFormGraph uses around 15-20% of my CPU.

I plot, with the PlotY, method around 50 points every 50ms.

If my application is in background or reduced in the task bar, it uses only 2-3% of the CPU but when the graph need to be refreshed, it use all the CPU.

This is my first problem.

 

The second one is a crash that occurred in the WaveFormGraph. I have an exception that I can not catch. I get this stack:

 

************** Texte de l'exception **************

System.InvalidOperationException: La collection a été modifiée ; l'opération d'énumération peut ne pas s'exécuter.

   à System.Collections.Hashtable.HashtableEnumerator.MoveNext()

   à NationalInstruments.UI.Internal.by.e(ComponentDrawArgsInternal A_0)

   à NationalInstruments.UI.Internal.by.b(ComponentDrawArgsInternal A_0)

   à NationalInstruments.Restricted.ControlElement.a(ComponentDrawArgsInternal A_0, Rectangle A_1, Boolean A_2)

   à NationalInstruments.Restricted.ControlElement.DrawChildren(ComponentDrawArgsInternal args, Rectangle clipRectangle)

   à NationalInstruments.Restricted.ControlElement.a(ComponentDrawArgsInternal A_0, Rectangle A_1, Boolean A_2)

   à NationalInstruments.Restricted.ControlElement.DrawChildren(ComponentDrawArgsInternal args, Rectangle clipRectangle)

   à NationalInstruments.Restricted.ControlElement.a(ComponentDrawArgsInternal A_0, Rectangle A_1, Boolean A_2)

   à NationalInstruments.Restricted.ControlElement.a(ComponentDrawArgsInternal A_0, Rectangle A_1)

   à NationalInstruments.Restricted.ControlElement.Paint(PaintEventArgs e)

   à NationalInstruments.UI.WindowsForms.ControlBase.OnPaint(PaintEventArgs e)

   à System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs e, Int16 layer, Boolean disposeEventArgs)

   à System.Windows.Forms.Control.WmPaint(Message& m)

   à System.Windows.Forms.Control.WndProc(Message& m)

   à System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)

   à System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)

   à System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

 

 

My application still runs but the graph only displays a red cross.

 

Thanks,

 

Norbert

0 Kudos
Message 1 of 3
(3,681 Views)
I would say that the CPU usage is justified (considering the plotting frequency - 20Hz).

Have you tried decimating, or cutting in half, the plotting frequency (after all, the human eye can only detect changes at around 10Hz - I think)

You can do a few things to improve performace (see the online help)

Anyhow, regarding the crash - I've had this happen to me.  I discovered that my data contained NaN values (these values caused my graphs to crash - red "X")

Good Luck
0 Kudos
Message 2 of 3
(3,624 Views)
Set the ProcessSpecialValues property on the plot object to true to make the plot properly handle NaN. Please be aware that this negatively impacts performance.
 
David Rohacek
National Instruments
0 Kudos
Message 3 of 3
(3,599 Views)