Breaking Change BC4941
Visible to All Users

WinForms - The WinApplication.Setup method runs in a separate thread

What happened
We run the WinApplication.Setup method in a separate thread and create templates for the logon and main form templates in the main UI thread. We do it if WinApplication.SplashScreen is set to null or an instance of DXSplashSceen.

Why we did this
These changes improve perceived performance as the logon and main forms are shown to end users earlier.

How to update your application
This change should not affect your application if you did not create custom templates for the following contexts: TemplateContext.PopupWindow andTemplateContext.ApplicationWindow.

Additional actions may be required in the following scenarios:
1. If you use custom templates for TemplateContext.ApplicationWindow based on the old DevExpress.ExpressApp.Win.Templates.MainForm template, replace the bar item image initialization code based on the ImageLoader.Instance.GetImageInfo method with the ImageOptionsHelper.AssignImage one.
Example:

C#
//FROM barMdiChildrenListItem.Glyph = ImageLoader.Instance.GetImageInfo("Action_WindowList").Image; barMdiChildrenListItem.LargeGlyph = ImageLoader.Instance.GetLargeImageInfo("Action_WindowList").Image; //TO ImageOptionsHelper.AssignImage(barMdiChildrenListItem.ImageOptions, "Action_WindowList");
Visual Basic
'FROM barMdiChildrenListItem.Glyph = ImageLoader.Instance.GetImageInfo("Action_WindowList").Image barMdiChildrenListItem.LargeGlyph = ImageLoader.Instance.GetLargeImageInfo("Action_WindowList").Image 'TO ImageOptionsHelper.AssignImage(barMdiChildrenListItem.ImageOptions, "Action_WindowList")

2. If you access the Application Model in custom templates for the TemplateContext.PopupWindow or TemplateContext.ApplicationWindowcontexts, check the XafApplication.Model property value in the XafApplication.CreateCustomTemplate event handler:
2.1.  If it is null (Nothing in VB), set the CreateCustomTemplateEventArgs.UseDefaultTemplate parameter to False and set the CreateCustomTemplateEventArgs.Template parameter tonull (Nothing in VB). To get a better startup performance, you can create all the required custom templates and cache them here.
2.2. If it is initialized, set the CreateCustomTemplateEventArgs.Template property to your custom template instance. If you cached your previously created templates, you can assign them here.
Example:

C#
static private CustomForm1 cachedCustomForm1; static private CustomForm2 cachedCustomForm2; static void xafApplication_CreateCustomTemplate(object sender, CreateCustomTemplateEventArgs e) { if(e.Application.Model == null) { if(e.Context == TemplateContext.ApplicationWindow) { cachedCustomForm1 = new CustomForm1(); cachedCustomForm2 = new CustomForm2(); e.UseDefaultTemplate = false; } } else { if(e.Context == TemplateContext.ApplicationWindow) { bool isRibbon = ((IModelOptionsWin)e.Application.Model.Options).FormStyle == RibbonFormStyle.Ribbon; if(isRibbon) { if(cachedCustomForm1 != null) { e.Template = cachedCustomForm1; } else { e.Template = new CustomForm1(); } } else { if(cachedCustomForm2 != null) { e.Template = cachedCustomForm2; } else { e.Template = new CustomForm2(); } } if(cachedCustomForm1 != null || cachedCustomForm2 != null) { cachedCustomForm1 = null; cachedCustomForm2 = null; } } } }
Visual Basic
Shared Private cachedCustomForm1 As CustomForm1 Shared Private cachedCustomForm2 As CustomForm2 Private Shared Sub xafApplication_CreateCustomTemplate(ByVal sender As Object, ByVal e As CreateCustomTemplateEventArgs) If e.Application.Model Is Nothing Then If e.Context Is TemplateContext.ApplicationWindow Then cachedCustomForm1 = New CustomForm1() cachedCustomForm2 = New CustomForm2() e.UseDefaultTemplate = False End If Else If e.Context Is TemplateContext.ApplicationWindow Then Dim isRibbon As Boolean = (CType(e.Application.Model.Options, IModelOptionsWin)).FormStyle Is RibbonFormStyle.Ribbon If isRibbon Then If cachedCustomForm1 IsNot Nothing Then e.Template = cachedCustomForm1 Else e.Template = New CustomForm1() End If Else If cachedCustomForm2 IsNot Nothing Then e.Template = cachedCustomForm2 Else e.Template = New CustomForm2() End If End If If cachedCustomForm1 IsNot Nothing OrElse cachedCustomForm2 IsNot Nothing Then cachedCustomForm1 = Nothing cachedCustomForm2 = Nothing End If End If End If End Sub

How to restore the previous behavior
Set the WinApplication.RunSetupInNewThread property to False in the Main method (YourSolutionName/Program.xx) before the WinApplication.Setup method call.

Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.