SciChart® the market leader in Fast WPF Charts, WPF 3D Charts, and now iOS Charting & Android Chart Components

Welcome to the SciChart Community Forums!

Please use the forums below to ask questions about SciChart. Take a moment to read our Question asking guidelines on how to ask a good question and our support policy

We also have a tag=SciChart on Stackoverflow.com where you can earn rep for your questions!

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.