Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DevExpress controls for WPF load time

When i use DevExpress controls for WPF-load time of the window on which they are declared-increases. But on second access-it loads fast. Isnt there a way to preload all of needed dll/themes on program startup (let it took 5-10 secs!), but load them fast in overall program? I've searched a bit, found something like this:

    private static void RunTypeInitializers(Assembly a)
    {
        Type[] types = a.GetExportedTypes();
        for (int i = 0; i < types.Length; i++)
        {
            RuntimeHelpers.RunClassConstructor(types[i].TypeHandle);
        }
    }

    private static void PreloadControls()
    {
        ThemeManager.ApplicationThemeName = Theme.Office2007BlueName;

        ThemeManager.SetThemeName(new TextEdit(), Theme.Office2007BlueName);
        ThemeManager.SetThemeName(new TreeListControl(), Theme.Office2007BlueName);

        RunTypeInitializers(Assembly.GetAssembly(typeof(TextEdit)));
        RunTypeInitializers(Assembly.GetAssembly(typeof(TreeListControl)));
        RunTypeInitializers(Assembly.GetAssembly(typeof(BarManager)));

        //GC.KeepAlive(typeof(TreeListControl));
        //GC.KeepAlive(typeof(BarManager));
        //GC.KeepAlive(typeof(TreeListView));
        //GC.KeepAlive(typeof(DevExpress.Xpf.Editors.Settings.MemoEditSettings));
        //GC.KeepAlive(typeof(DevExpress.Xpf.Editors.Settings.TextEditSettings));
    }

But non of that helps. First load is still long.

like image 636
0x49D1 Avatar asked Jun 01 '11 09:06

0x49D1


1 Answers

To resolve this issue, I suggest that you ngen our assemblies and use the DXSplashWindow (11.1) or create a similar window manually and show it when the main form opens for the first time.

This slowdown is caused by JIT and theme loading.

The RunTypeInitializers simply calls an object constructor. WPF themes are not loaded at this moment because this happens only when a control is about to be shown and the visual tree is generated.

A possible solution to this problem is to create an invisible window which will contain all our controls, then show and hide it. However, I do not like this approach. In my opinion, it is better to show a splash window.

like image 62
DevExpress Team Avatar answered Sep 29 '22 10:09

DevExpress Team