DevExpress controls for WPF load time

文章探讨了使用DevExpress控件时,WPF窗口加载时间增加的问题,并提供了解决方案,包括预加载DLL和主题,以及使用自定义启动窗口减少延迟。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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.
wpf performance controls devexpress
link|improve this question
    
asked Jun 1 at 9:34
0x49D1
1,122415

94% accept rate
    
    
Here such question was answered: devexpress.com/Support/Center/p/B201967.aspx – 0x49D1 Jun 29 at 6:57
feedback
1 Answer
active oldest votes
up vote 1 down vote accepted
    

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.
link|improve this answer
    
answered Jun 2 at 9:01
DevExpress Team
7,3492413
    
    
Thank you for the answer. Does DXSplashWindow preload WPF themes when its showed, or i must create own splash window with calls to DX WPF controls to show them first time? – 0x49D1 Jun 2 at 12:52
    
I have ngen-ed my assemblies and started application again. When i open windows with devexpress controls-it takes lot of time again..So i think that i experience here the problem with WPF themes you described. I'll try invisible window, until you answer about Devexpress's native splash. – 0x49D1 Jun 2 at 13:03
    
Made the following: added own splashscreen with XtraGrid on it. I show that screen on application start and close after it loads. Still no performance improvements when opening other windows with devexpress components-the first of them starts a bit slowly, but after- even if i close the one-others load really fast! – 0x49D1 Jun 2 at 13:18
    
The DXSplashWindow cannot improve the application performance. This is just a convenient way to ask the end-user to wait during a long operation. – DevExpress Team Jun 3 at 8:03

转载于:https://www.cnblogs.com/luoyaoquan/archive/2011/07/30/2121858.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值