Pre loader

ViewportManager.SuspendUpdates()

Welcome to the SciChart Forums!

  • Please read our Question Asking Guidelines for how to format a good question
  • Some reputation is required to post answers. Get up-voted to avoid the spam filter!
  • We welcome community answers and upvotes. Every Q&A improves SciChart for everyone

WPF Forums | JavaScript Forums | Android Forums | iOS Forums

1
0

How exactly does the SuspendUpdates work? I was under the impression that the surface the ViewportManager is attached to should not be redrawn until the IUpdateSuspender was disposed.

        using (var s = ViewportManager.SuspendUpdates())
        {
            // Clear ObservableCollection<IChartSeriesViewModel> that is databound to SciChartSurface.SeriesSource
            // Add new IChartSeriesViewModel to ObservableCollection
        }

The behavior I’m observing is after the clear it is blanking out the chart and then I see the new series drawn on the surface. I was expecting to see the chart immediately switch to the new series without first seeing the chart surface being cleared. Is this not the behavior of SuspendUpdates?

  • You must to post comments
0
0

Hi there,

This is a good question. Our ISuspendable documentation says

    /// <summary>
    /// Suspends drawing updates on the target until the returned object is disposed, when a final draw call will be issued
    /// </summary>
    /// <returns>The disposable Update Suspender</returns>
    IUpdateSuspender SuspendUpdates();

However, we have actually used ISuspendable throughout SciChart as a nice, clean thread-safe pattern to pause/resume operations on many elements. So it actually has subtle differences for different elements.

Here is a quick summary / run-down of what ISuspendable does on different elements:

  • Annotations: When suspended, prevents positioning of the annotation
  • ViewportManager: When suspended, prevents re-calculating YAxis, XAxis ranges
  • SciChartSurface: When suspended, prevents re-drawing of the chart.
  • DataSeries: When suspended, locks the ParentSurface.SyncRoot, preventing re-draw on the chart. Also prevents concurrent updates from causing threading issues.
  • Axis: When suspended, prevents drawing of axis labels and ticks

That’s pretty much all the classes that implement ISuspendable. If you are wanting to freeze the chart from inside a view model, I would recommend one of two strategies:

  1. You can call DataSeries.SuspendUpdates(), which will lock the parent surface, only if the data series is attached. There are known issues if a DataSeries is a child of more than one SciChartSurface.

  2. You can inject your SciChartSurface as ISuspendable into your view model and control it directly.

  3. If (2) is upsetting, as it breaks MVVM, you can create an attached behaviour which controls SciChartSurface.SuspendUpdates via a boolean property. I would not personally recommend this approach as it can result in threading issues. One of the beauties of ISuspendable.SuspendUpdates() is it is truly nested, and thread-safe.

  4. Another option is to lock SciChartSurface.SyncRoot directly. This should only be used for short operations but can be used to freeze the render thread temporarily

I hope this clarifies the Api and when / where you should suspend chart drawing!

Best regards,
Andrew

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.

Try SciChart Today

Start a trial and discover why we are the choice
of demanding developers worldwide

Start TrialCase Studies