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?
- Arne Dumarey asked 8 years ago
- last edited 8 years ago
- You must login to post comments
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?
- Andrew Burnett-Thompson answered 8 years ago
-
I tried unsubscribing, but it doesn’t help
-
We have an example that Exports to file here: https://www.scichart.com/wpf-export-screenshot-options-chart/ and it doesn’t hang. The only difference between this and your code sample is you are doing it in SciChartSurface.Rendered handler (hence that was my best guess).
- You must login to post comments
Please login first to submit.