From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

MStudio ScatterGraph crashes in a Visual C# based Windows Application

I have a windows application written in Visual C# 2012. I am capturing Analog Input from a USB 6009 DAQ card. 

I am using MStudio's ScatterGraph component to read the analog input signal from the DAQ device. However, majority of the times, the graph crashes and I get a white box with a red X on it! See screenshot of the crash.

 

Note that the analog input data is still being loaded into the application, since I am able to compute the average peak signal and have it displayed on a text box, but it just that the real time update of the data cannot be seen. I have to close out of the application and re-run it and hope everytime that it doesn't crash again! The application uses a async call to allow for analog I/O without freezing up the application when any process is in progress!

 

Desperately need help to fix this before I can build a commercial version of this application. Does mstudio allow logging the crash info somewhere within the application or Visual Studio  to debug the problem related to this scattergraph object? Any other alternatives? Thank you very much for your assistance. 

0 Kudos
Message 1 of 9
(5,545 Views)

Hi,

 

Do you know of any pattern that seems to cause this error to occur or does it seem to occur somewhat randomly? Visual Studio can log crashes as described in brief here: https://msdn.microsoft.com/en-us/library/ms241272.aspx, however if an error isn’t being thrown the IDE may not view it as a crash. You should be able to use any Visual Studio debugging tools with Measurement Studio.


-Kevin

0 Kudos
Message 2 of 9
(5,519 Views)

Thanks Kevin.

It doesn't throw an error in VStudio v11 2012 and that is part of the problem. I have monitored the 'output' in VStudio after each step in the application, but there is no error to be seen. I am guessing it is because the graph is a mstudio component as opposed to one that is coded up from ground up?

 

As regards a pattern, I have observed that it only occurs in the first few seconds after capturing the analog signal on the graph. Once the graph has run successfully for say over 10 seconds, then rarely does it ever crash after that!! I have seen it run without problem for more than an hour after that initial shaky phase! The graph crash rate (in the first 10 seconds) is estimated at over 80%!! So, I have to keep re-running the solution file until the graph doesn't crash in the first 10 seconds and then I am good to go. Does that tell you something? Thanks again. - Sid

0 Kudos
Message 3 of 9
(5,503 Views)

It should still be registering any errors that it sees with Measurement Studio components. Its interesting that this error will be avoided around 10-20% of the time. Typically behavior like that suggests something like a race condition causing the graph to somehow be in an inconsistent state. You may want to double check that your application is doing operations in an order that you expect.

 

-Kevin

0 Kudos
Message 4 of 9
(5,480 Views)

Hi,

 

I had the same problem just lately.

 

It's was caused by trying to update the Graph from a thread that isn't the UI thread.

In Vb.net the solution for me was: -

 

Delegate Sub updateGraphUI()

Private Sub ()

' InvokeRequired required compares the thread ID of the

' calling thread to the thread ID of the creating thread.

' If these threads are different, it returns true.

If Me.Graph.InvokeRequired Then

   Dim updateGraph As New updateGraphUI(AddressOf Me.updateGraph)

Else

   updateGraph()

End If

End Sub

Private Sub updateGraph()

   Me.Graph.PlotY(_ydata(_activeChannel), StartX, deltaX)

End Sub

 

StevieB

Message 5 of 9
(5,467 Views)

Thanks Kevin and StevieB. I wil check on both your solutions and report back. - Sid

0 Kudos
Message 6 of 9
(5,442 Views)

Kevin and StevieB (or anybody else please),

 

I am back after some troubleshooting, but still haven't figured out a solution to the graphing crash. Here are things for your kind review (notepad++ renders it well):

 

1. I have attached the activitylog.xml file and there are no errors in there. Does this still tell you something?

 

2. I am also sending you code for the graphing function with comments. Would you please take a look at it and see where the problem is? StevieB, your code is great, but not entirely clear to me 😞  May be the attached snippet can help you pinpoint the problem? 

 

3. Specific to the graphs dll, I see that under file description of 'NationalInstruments.Controls.Graphs.dll', it states NI WPF Graph Control,  while my application is a Windows Form Application. Does that matter?

 

Thank you very much for your help and suggestions. 

 

Sid

Download All
0 Kudos
Message 7 of 9
(5,393 Views)

Anybody who can help, please? Thank you. Sid

0 Kudos
Message 8 of 9
(5,335 Views)

Sid,

 

The code snippett you provided should work. If possible you may want to contact NI support (ni.com/contact-us/) to have an engineer look specifically at this problem.

 

Kevin

0 Kudos
Message 9 of 9
(5,322 Views)