Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

Program's Range adjust lag on first call

Solved!
Go to solution

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
}

 

 

 

0 Kudos
Message 1 of 8
(3,824 Views)

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.

~ Paul H
0 Kudos
Message 2 of 8
(3,818 Views)

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!

 

0 Kudos
Message 3 of 8
(3,813 Views)

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).

~ Paul H
0 Kudos
Message 4 of 8
(3,803 Views)

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!

 

 

 

0 Kudos
Message 5 of 8
(3,800 Views)

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'

 

 

0 Kudos
Message 6 of 8
(3,792 Views)
Solution
Accepted by topic author kirko7

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 );

~ Paul H
0 Kudos
Message 7 of 8
(3,790 Views)

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

0 Kudos
Message 8 of 8
(3,786 Views)