title: What is happening between method call and method entry (C#)?
body: <p>At the moment we have a problem with the startup of a middle-sized WPF-application. It takes about 15 seconds to load completly. We wondered what it takes that long.</p>
  
  <p>In the event Application_Startup of App.xaml a controller gets initialised. This controller lives in a separate 'business' assembly, which calls in turn to the 'data' assembly to gather information about the user and so on. This assemblies are relative small, 160k and 60k.</p>
  
  <p>The time it takes to enter this event was 15 seconds. So we separated the code in another method and call it in the event. With this change, we found the debugger enter the Application_Startup event directly after startup. However, from the point it reaches the line which calls the separated method and enters this methods it took again 15 seconds.</p>
  
  <p>In this period of time nothing happend in the output or callstack window of Visual Studio. So questions are:</p>
  
  <ol>
  <li>Is there any way to see what is happening after a method call and before entering the method?</li>
  <li>Are assemblies needed in a method loading in this period of 15 seconds? If true, what are ways to shorten this time?</li>
  </ol>
  
  <p>Thanks in advance for replies.</p>
  
  <p>edit, the requested code of the separated method:</p>
  
  <pre><code>        try
          {
              // Check whether debug mode is enabled or not.
              string[] commandArgs = Environment.GetCommandLineArgs();
              ApplicationLog.DebugMode =
                  (commandArgs.Length &gt; 1 &amp;&amp;
                  (commandArgs[1].IndexOf("debug") &gt; 0) ||
                  (commandArgs.Length &gt; 2 &amp;&amp; commandArgs[2].IndexOf("debug") &gt; 0));
  
              // Logging startup.
              ApplicationLog.Log("Starting at " + Environment.MachineName, 21003);
  
              // Check to start configtool or main application.
              if (commandArgs.Length &gt; 1 &amp;&amp;
                  (commandArgs[1].IndexOf("config") &gt; 0 || commandArgs[2].IndexOf("config") &gt; 0))
              {
                  ConnectionStringWindow window = new ConnectionStringWindow();
                  window.DataContext = new ViewModels.ConnectionStringViewModel();
                  window.Show();
              }
              else
              {
                  // The main window.
                  MainWindow mainWindow = new MainWindow();
                  mainWindow.Closing += mainWindow_Closing;
  
                  // New ViewModel.
                  mainWindow.DataContext = new ViewModels.MainWindowViewModel(mainWindow);
  
                  // Display.
                  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);
              }
  
              // Close application.
              Application.Current.Shutdown();
          }
  </code></pre>