Pre loader

Tag: multithread

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 vote

I am working on a multithreaded application where the acquisition and chart display run on different threads. I am attempting to collect samples and plot only when I have 100 samples available to have less resource consumption and keep the application responsive. However, when I change the number of samples in the block, my FIFO capacity seems to change, allowing significantly less amount of samples than the ones I need. The current FIFO capacity should allow for at least 16 mins worth of data, but it only shows less than a second

If I set the block size to 1 (single sample appending) I obtain the results I need, but I am seeing performance issues in other areas of the program, hence the need of appending in blocks.

See the attachments for more clarity. Any suggestions?

EDIT: Adding code

private void DisplayNPD()
            XyDataSeries<float, float> npdRawDataSeries = new XyDataSeries<float, float>();
            int fifoSize = 1000000;
            npdRawDataSeries.FifoCapacity = fifoSize;
            npdRawData_RS.DataSeries = npdRawDataSeries;

            double npdRaw = 0;
            bool successfulDequeue = false;
            int samplesQueued = 0;
            int samplesInBlock = 100;
            float[] rawSamples = new float[samplesInBlock];
            float[] time = new float[samplesInBlock];

            while (!ImagingSession.terminateThreads)
                if (ImagingSession.laserOnOff && !graphRestarted)
                    int npdElementsInQueue = npdDisplayQueue.Count;
                    if (npdElementsInQueue > 0)
                        successfulDequeue = npdDisplayQueue.TryDequeue(out npdRaw);

                    if (successfulDequeue)
                        currentTime = graphStopwatch.ElapsedMilliseconds * 0.001;
                        time[samplesQueued] = (float) currentTime;
                        rawSamples[samplesQueued] = (float) (npdRaw * 1000);

                        if (samplesQueued == samplesInBlock)
                            using (npdRawDataSeries.SuspendUpdates())
                                npdRawDataSeries.Append(time, rawSamples);
                            samplesQueued = 0;

                            if (currentTime > upperLimit)
                                lowerLimit = upperLimit;
                                upperLimit += xAxisWidth;
0 votes


I have a question concerning multithreaded access to the DataSeries:

We implemented an overview for our chart as described here. This works fine when we load data, add it to the series and then display it.

Now, for a certain use case we need to display live data. We implemented this in a background thread. We noticed that after some time the application freezes when the update frequency rises. In the documentation I found this:

NOTE: Considerations when a DataSeries is shared across multiple chart surfaces. Currently only a single parent chart is tracked, so DataSeries.SuspendUpdates() where the DataSeries is shared may have unexpected results.

I guess this is what is happening here…so what is the recommended approach to achieve something like this? Do we have to add the data on the UI thread if we want to have the Overview? Here it says:

When appending Data in a background thread, you cannot share a DataSeries between more than one SciChartSurface. You can still share a DataSeries between more than one RenderableSeries.

Does that mean we should create more different RenderableSeries for the main chart surface and the overview surface that are based on the same DataSeries? Any help would be appreciated!

1 vote

I have a lot of data to process and I don’t want UI to get frozen. So I’d like to add data in a background thread.

Is it possible to append data to XyDataSeries in a separate thread? Is it supposed to handle this safely?

Showing 3 results