Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

Add the FIRST ScatterPlot to ScatterGraph(C#),speed very slow(6+Sec);If I put this to background thread,NI Chart crashed.

When I add the FIRST ScatterPlot to ScatterGraph(C#),speed is very slow at least 6 seconds,Even I just add 2 points to ScatterPlot;
If I put this thread to background,NI Chart crashed.
{
....
private NationalInstruments.UI.XAxis m_xAxes,m_yAxes;
private NationalInstruments.UI.WindowsForms.ScatterGraph m_chart;
....
ScatterPlot plot = new ScatterPlot(m_xAxes, m_yAxes);
....
m_chart.Plots.Add(plot);
}

Who can help me to resolve this problem?
Thanks in advance for your help.
0 Kudos
Message 1 of 5
(4,021 Views)
I dont know if that will help you, but the ctor you are using is :

public ScatterPlot ( NationalInstruments.UI.XAxis xAxis , NationalInstruments.UI.YAxis yAxis )

and then m_yAxes should be declared NationalInstruments.UI.YAxis .


Pipo
0 Kudos
Message 2 of 5
(4,011 Views)
Pipo is correct, although I suspect that it's a typo because calling a ScatterPlot constructor with 2 X axes instead of 1 X axis and 1 Y axis would not compile.

Regarding the crash when you try to do this on a separate thread, this is because Windows Forms controls are not thread safe. Notice that the class overviews of all .NET Framework and Measurement Studio Windows Forms controls have a thread safety section that states:

"Only the following members are safe for multithreaded operations: BeginInvoke, EndInvoke, Invoke, InvokeRequired, and CreateGraphics."

For more information about accessing Windows Forms controls from non-UI threads, see the .NET Quickstart article "Making procedure calls across thread boundaries".

Regarding the slow startup time, where are you running this code? Is it in the constructor or at form load time? Does this only happen when you add a plot, or does it happen anytime you try to start an application that has a Measurement Studio graph? Take a look at the knowledge base article "Measurement Studio .NET Assemblies Take More Than 10 Seconds to Load at Run Time" and see if this is the cause of your problem. If not, could you please post a small test project that reproduces this behavior? Thanks.

- Elton
0 Kudos
Message 3 of 5
(4,000 Views)
Thank you, Pipo!
Thank you, Elton!
I copy the wrong code to the board in a hurry.Yes,Elton,If add with 2 X axes,the compile can not pass.
The correct code is:
{
....
public NationalInstruments.UI.XAxis m_xAxes;
public NationalInstruments.UI.YAxis m_yAxes;
public NationalInstruments.UI.WindowsForms.ScatterGraph m_chart;
....
ScatterPlot plot = new ScatterPlot(m_xAxes, m_yAxes);
....
m_chart.Plots.Add(plot);
}

Elton,I am reading the "Measurement Studio .NET Assemblies Take More Than 10 Seconds to Load at Run Time" for details.If can not resolve my problem,I will post a small test project that reproduces this behavior.Thanks in advance.
Can you tell me your email address to maxj@xbow.com?Thanks.
0 Kudos
Message 4 of 5
(3,989 Views)
You don't have to e-mail the project. You can just attach it to a post in these forums.

- Elton
0 Kudos
Message 5 of 5
(3,968 Views)