Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
967 views
in Technique[技术] by (71.8m points)

performance - 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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
...