We are currently having a problem launching a medium-sized, medium sized WPF application. A full download takes about 15 seconds. We wondered what was needed for this.
In case Application_Startup from App.xaml is initialized by the controller. This controller is in a separate assembly "business", which in turn calls the assembly of "data" to collect information about the user, etc. These assemblies are relatively small, 160k and 60k.
The time required to enter this event is 15 seconds. Therefore, we divided the code by another method and call it in this case. With this change, we found that the debugger fires the Application_Startup event immediately after launch. However, from the point it reaches the line that calls the selected method and introduces these methods, it took another 15 seconds.
During this time period, nothing happens in the output window or the Visual Studio call window. Therefore, the questions:
- Is there a way to see what happens after the method is called and before the method is entered?
- Are assemblies necessary when loading the method for this period of 15 seconds? If true, what are the ways to reduce this time?
Thanks for answers.
edit, the requested code of the split method:
try
{
string[] commandArgs = Environment.GetCommandLineArgs();
ApplicationLog.DebugMode =
(commandArgs.Length > 1 &&
(commandArgs[1].IndexOf("debug") > 0) ||
(commandArgs.Length > 2 && commandArgs[2].IndexOf("debug") > 0));
ApplicationLog.Log("Starting at " + Environment.MachineName, 21003);
if (commandArgs.Length > 1 &&
(commandArgs[1].IndexOf("config") > 0 || commandArgs[2].IndexOf("config") > 0))
{
ConnectionStringWindow window = new ConnectionStringWindow();
window.DataContext = new ViewModels.ConnectionStringViewModel();
window.Show();
}
else
{
MainWindow mainWindow = new MainWindow();
mainWindow.Closing += mainWindow_Closing;
mainWindow.DataContext = new ViewModels.MainWindowViewModel(mainWindow);
mainWindow.Show();
}
}
catch (Exception ex)
{
ApplicationLog.Log(ex, 22001);
if (ApplicationLog.DebugMode)
{
Microsoft.SqlServer.MessageBox.ExceptionMessageBox box = new Microsoft.SqlServer.MessageBox.ExceptionMessageBox(
ex.Message,
"Application",
Microsoft.SqlServer.MessageBox.ExceptionMessageBoxButtons.OK,
Microsoft.SqlServer.MessageBox.ExceptionMessageBoxSymbol.Error);
box.InnerException = ex;
box.ShowCheckBox = false;
box.Show(null);
}
else
{
MessageBox.Show(ex.Message, "Application", MessageBoxButton.OK, MessageBoxImage.Error);
}
Application.Current.Shutdown();
}