Pre loader

On rendered ExportToFile hangs

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

0
0

Hi,

I have a function that needs to export the chart when it’s rendered.

    ...
    sciChartSurface.Rendered += SciChartSurface_Rendered;
}

private void SciChartSurface_Rendered(object sender, EventArgs e)
    {
        var surface = sender as SciChartSurface;
        if (surface != null)
        {
            surface.ExportToFile(ImageFullFilename, ExportType.Png);


            surface.Rendered -= SciChartSurface_Rendered;
            ...
        }
    }

However the export to file hangs…

Any ideas how to fix this?

Update

Changing to the following code works…

private async void SciChartSurface_Rendered(object sender, EventArgs e)
    {
        var surface = sender as SciChartSurface;
        if (surface != null)
        {
            await Task.Run(() =>
            {
                Thread.Sleep(2000);
            });
            surface.ExportToFile(ImageFullFilename, ExportType.Png);


            surface.Rendered -= SciChartSurface_Rendered;
            ...
        }
    }

So if I’m too early in the lifecycle of the render, where in the cycle can I be sure it’s done?

Version
3.5
  • You must to post comments
0
0

ExportToFile requires a render, so its likely you are getting stuck in an infinite loop because of doing export inside the Rendered event.

Have you tried unsubscribing from SciChartSurface.Rendered BEFORE exporting?

  • 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