09-06-2016 09:02 AM
Hi, I just noticed this lag but turns out it's always been there.
Basically I have 2 buttons on the screen - "Ave" and "Std". The default display is Ave and when I click the Std button, RangeY is programatically adjusted based on the current button selection. For some reason there's lag on the first Std click and then it's all good going back and forth between Ave and Std.
Thanks
private Range<double> m_rangeY; public Range<double> RangeY { get { return m_rangeY; } set { m_rangeY = value; OnPropertyChanged("RangeY"); } }
Range<double> range = ShowAve ? Ave.RangeY : Std.RangeY;
// If range was not set then auto adjust
if (range.Minimum == 0 && range.Maximum == 0)
{
RangeYAdjuster = RangeAdjuster.FitExactly;
}
else
{
RangeYAdjuster = RangeAdjuster.None;
RangeY = range; // If I comment this line out, there's no lag
}
Solved! Go to Solution.
09-06-2016 10:20 AM
I was not able to reproduce the issue based on the description you provided. Attached is a small example project based on your sample code that uses bindings for the axis range and adjuster.
09-06-2016 11:08 AM - edited 09-06-2016 11:09 AM
Thank you. Your code does work without lag.
I added some code to yours to reproduce the lag though. Seems like the issue is going from negative to positive... If you change -8 to anything positive, there's no lag.
Please see the attached file where I indicated my changes with "// MY CHANGE" string.
Thanks for the quick respnse!
09-06-2016 12:35 PM
Thank you for the update. Unfortunately, I still cannot reproduce the lag you are seeing, even with your changes. Did you modify anything in the XAML besides naming the graph "GraphMain"?
One other thought I did have: since you are modifying multiple properties at once (data source, range, and adjuster), there may be an ordering issue where updating one property will prevent another from taking effect. For example, if the data source gets processed while the adjuster is still set to "Fit", that may interfere with the range assignment from the binding. To avoid this, you could try performing the changes between BeginInit
/EndInit
calls on the graph (in the example, this would happen in OnRadioButtonChecked
).
09-06-2016 12:53 PM
No, no other changes besides setting GraphMain name in XAML code.
Interesting... What version of NI are you running? 2015? I'm on 2015 but without f1 anf f5 patches (installing at the moment and will re-test as soon as it's done).
I will also try your ordeging suggestion. Will get back
Thanks!
09-06-2016 01:17 PM
Update didn't solve this issue.
I just checked the Output window to see what happens on my Std click event and this is what's happening (see below). This only happens on the initial Std click and must be source of lag.
'PropertyLag.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\SharpDX.Direct3D10\v4.0_2.4.1.0__627a3d6d1956f55a\SharpDX.Direct3D10.dll'
'PropertyLag.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\SharpDX\v4.0_2.4.1.0__627a3d6d1956f55a\SharpDX.dll'
'PropertyLag.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\SharpDX.Direct3D9\v4.0_2.4.1.0__627a3d6d1956f55a\SharpDX.Direct3D9.dll'
'PropertyLag.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\SharpDX.Direct3D11\v4.0_2.4.1.0__627a3d6d1956f55a\SharpDX.Direct3D11.dll'
'PropertyLag.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\SharpDX.DXGI\v4.0_2.4.1.0__627a3d6d1956f55a\SharpDX.DXGI.dll'
'PropertyLag.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\SharpDX.D3DCompiler\v4.0_2.4.1.0__627a3d6d1956f55a\SharpDX.D3DCompiler.dll'
09-06-2016 01:33 PM
I am using Measurement Studio 2015 in Visual Studio 2013.
Those lines in the Output window indicate the graph is receiving/rendering data for the first time when Std is clicked.
To rule out an ordering issue, one other change you could try is to move the data source assignment to happen after the bindings have run:
Dispatcher.BeginInvoke( new Action( delegate {
GraphMain.DataSource = ShowAve ? GetArrayAve( ) : GetArrayStd( ); // MY CHANGE
} ), DispatcherPriority.DataBind - 1 );
09-06-2016 01:38 PM - edited 09-06-2016 01:47 PM
Yep, the ordering change did it!
Thank you!
Edit: I didn't even have to make any delegate changes... just called Graph.DataSource AFTER setting Range