Pre loader

First time delay adding chart in usercontrol

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

I’m seeing a delay the first time I add a chart to scichart:SciChartSurface. Subsequent loads are much faster. It looks like the initial initialization is taking time—what can I do to reduce or eliminate this first-load delay?

where ChartDocumentControl

Version
8.5.0.28148
  • You must to post comments
0
0

Hi Karthikeyan,

There’s some information in the SciChart WPF Documentation on Startup Application Performance.

Basically, there’s a 300ms static cost for initializing the SciChart WPF 2D/3D graphics engine (once per application) plus some additional time for first chart creation. This can be done at launch of your application by using this code:

        // Edit app.xaml.cs 
        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);

            // Async load libraries and apply license
            //
            // This code should be called and awaited before any SciChartSurface or SciChart3DSurface is shown
            //
            // Use SciChart.Charting3D.SciChart2D3DInitializer if you use both 2D & 3D charts in your app. Note this also initializes 2D libraries
            // Use SciChart.Charting.Visuals.SciChart2DInitializer if you use only 2D charts in your app
            //
            // Options: runtimeLicenseKey should be set to your license key
            //          tempDirectory is an optional temp directory for loading native libraries. Leave null for the default

            string runtimeLicenseKey = "your license keycode here";
            string tempDirectory = null;

            var initTask = SciChart2D3DInitializer.LoadLibrariesAndLicenseAsync(runtimeLicenseKey, tempDirectory);

            // You can either await initTask or use SciChart2D3DInitializer.Awaiter
            // to do the same thing later on (see MainWindow.xaml.cs)
        }

        // Edit mainwindow.xaml.cs (or elsewhere in your application startup)
        private async void MainWindowLoaded(object sender, RoutedEventArgs e)
        {
            // Wait for the license initialization we triggered in App.xaml.cs
            await SciChart2D3DInitializer.Awaiter;

            // Now swap out content for SciChartSurfaces once lienses loaded
            this.root.Children.Clear();
            this.root.Children.Add(new SciChartContent());
        }

Also, you can find a video tutorial about asynchronous SciChart loading on our YouTube channel and download a sample project from GitHub.

It’s also possible to Asynchronously startup the 2D/3D graphics engine in SciChart WPF version 8 onwards. We do this in our own SciChart WPF demo app while the splash screen is being shown.

    // App.xaml.cs
    public App()
    {
        // Start Visual Xccelerator Engine asynchronously
        Task.Run(() =>
        {
            try
            {
                VisualXcceleratorEngine.UseAutoShutdown = false;
                VisualXcceleratorEngine.RestartEngine();
            }
            catch
            {
                // Suppress Vx init errors. In this case rendering                    // will occur with a fallback to a software renderer
            }
        });
        // Do other app initialization
        InitializeComponent();
    }

For more information, take a look at the Bootstrapper.cs file in the SciChart.Wpf.Examples repository. This shows you how to do this in the most efficient way.

Best regards,
Andrew

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.