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 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…