Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

Graph Probelm

I'm currently using the plotting capablities of NI Measurement Studio. One probelm I find is sometimes I get this strange error when I'm not updating the NI graph or trying to access the NI graph in anyway and my program is sleeping waiting for some hard to sync.

 

This is the error I get:

System.InvalidOperationException was unhandled
  Message=Collection was modified; enumeration operation may not execute.
  Source=mscorlib
  StackTrace:
       at System.Collections.Hashtable.HashtableEnumerator.MoveNext()
       at NationalInstruments.UI.Internal.XYGraphPlotAreaManager.b(Graphics A_0, Rectangle A_1, ArrayList A_2)
       at NationalInstruments.UI.Internal.XYGraphPlotAreaManager.a(Graphics A_0, Rectangle A_1, Boolean A_2)
       at NationalInstruments.UI.Internal.XYGraphPlotAreaManager.DrawGridLines(ComponentDrawArgsInternal args, Boolean layout)
       at NationalInstruments.UI.Internal.XYGraphPlotAreaManager.DrawForeground(ComponentDrawArgsInternal args)
       at NationalInstruments.Restricted.ControlElement.a(ComponentDrawArgsInternal A_0, Rectangle A_1, Boolean A_2)
       at NationalInstruments.Restricted.ControlElement.DrawChildren(ComponentDrawArgsInternal args, Rectangle clipRectangle)
       at NationalInstruments.Restricted.ControlElement.a(ComponentDrawArgsInternal A_0, Rectangle A_1, Boolean A_2)
       at NationalInstruments.Restricted.ControlElement.a(ComponentDrawArgsInternal A_0, Rectangle A_1)
       at NationalInstruments.Restricted.ControlElement.Paint(PaintEventArgs e)
       at NationalInstruments.UI.WindowsForms.ControlBase.OnPaint(PaintEventArgs e)
       at System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs e, Int16 layer)
       at System.Windows.Forms.Control.WmPaint(Message& m)
       at System.Windows.Forms.Control.WndProc(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
       at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
       at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
       at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
       at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
       at System.Windows.Threading.Dispatcher.Run()
       at System.Windows.Application.RunDispatcher(Object ignore)
       at System.Windows.Application.RunInternal(Window window)
       at System.Windows.Application.Run(Window window)
       at System.Windows.Application.Run()
       at NeutronAnalyst.App.Main() in C:\Users\Photogenics\Desktop\New folder\NeutronAnalyst\NeutronSpectroscopyAnalyst\obj\Debug\App.g.cs:line 0
       at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException: 

any thoughts?

0 Kudos
Message 1 of 6
(4,202 Views)

Photogenics,

 

Does this happen on a regular interval or sleeping period? If so, how long/how many iterations? Does it happen if you run this on multiple computers?

 

Which version of MS and VS are you using? 

 

Regards,

 

Kyle Mozdzyn

Applications Engineering

National Instruments

Regards,

Kyle M.
Applications Engineering
National Instruments
0 Kudos
Message 2 of 6
(4,194 Views)

First let me explain the application better. The program I created interfaces with some data acquisition hardware. It then takes this data, processes and plots the results on the screen using an NI Plotting functions from MS. These tasks are done in serial order, continuously. This particular error seems to randomly, sometimes after 5 minutes, or 20 minutes and other times after a few hours. It always occurs while the DAQ thread is sleeping waiting for the hardware to be ready for data acquisition. During this time, the NI graph is not being updated with new information and this just displayed the previously collected results.

 

This error only happens one computer since we only have the hardware connected to one computer. So it's hard to say what could happen on multiple computers.

 

And currently with this project I am using MS 2009 with VS 2010.

0 Kudos
Message 3 of 6
(4,190 Views)

Photogenics,

 

What hardware are you using for this? If its a USB device, you could have your USB sleeping for power saving reasons. For testing purposes, what happens if you keep the DAQ device busy with a simple idling task running when your main program isnt? 

Regards,

Kyle M.
Applications Engineering
National Instruments
0 Kudos
Message 4 of 6
(4,181 Views)

Were using a GaGe digitizer which interfaces with a PCI express card in the computer. I don't think the error has nothing do with the error, since the hardware isn't being used when this error occurs. The sleep function call I'm taking about is a System.Threading.Sleep( 1 sec ) call which I explicitly use. 

 

 

0 Kudos
Message 5 of 6
(4,178 Views)

Photogenics,

 

On failure, can you step into the code and track where the issue is coming from? If so could you provide a snippit from there, with the context its being used in? There is quite a bit going on and I would like to get some more information as to the context for things. 

Regards,

Kyle M.
Applications Engineering
National Instruments
0 Kudos
Message 6 of 6
(4,172 Views)