6

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.

0x49D1
  • 8,505
  • 11
  • 76
  • 127

1 Answers1

5

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.

DevExpress Team
  • 11,338
  • 2
  • 24
  • 23
  • 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 02 '11 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 02 '11 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 02 '11 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 03 '11 at 08:03
  • Can you please provide some sample code.. Because when i try to initialize all needed for me controls and then open another window with Bar and Grid(for example)-UI still freezes for first time load. NGen didnt help much, so i think its devexpress's theme load problems. – 0x49D1 Jun 17 '11 at 13:16
  • 1
    I have posted the code at: http://www.devexpress.com/Support/Center/Issues/ViewIssue.aspx?issueid=Q226845 – DevExpress Team Jun 17 '11 at 17:00
  • Thank you very much, i'll try it as soon as i'll have access to my project! By the way, improved responsiveness significantly with UI Automation fix, provided here: http://devexpress.com/Support/Center/p/Q303574.aspx – 0x49D1 Jun 18 '11 at 07:20
  • By the way, SplashScreen works just fine, but the problem with preloading devexpress themes/assemblies-is still there.. – 0x49D1 Jun 21 '11 at 07:20
  • My question was almost this one: http://www.devexpress.com/Support/Center/p/Q255924.aspx , but the method there doesnt help with loading EVERYTHING on startup. First call to devexpress controls is still slow. – 0x49D1 Jun 21 '11 at 07:31
  • Hi, we would like to ask you to post a sample showing the slowdown to the support center(http://www.devexpress.com/support/center). We will profile the application and let you know what causes this slowdown and how to avoid it. – DevExpress Team Jun 21 '11 at 21:06