title: Start WPF app with async services
body: <p>I am trying to load some background services that check some information in the internet, while the application is loading and showing the splash screen. Further, if the splash screen's progress has finished, it should show up the mainwindow and continue to work, periodically checking for updates in the web.</p>
  
  <p>I have tried using this for the App:</p>
  
  <pre><code>    public IpSumApp()
      {
          ApplicationInitialize = _applicationInitialize;
      }
  
      public static new IpSumApp Current
      {
          get { return Application.Current as IpSumApp; }
      }
  
      public MainWindow mainwindow;
  
      public Watch_Service SurveillanceSystem;
  
      internal delegate void ApplicationInitializeDelegate(Splash splashWindow);
      internal ApplicationInitializeDelegate ApplicationInitialize;
  
      private void _applicationInitialize(Splash splashWindow)
      {
          double progressbar = 0;
  
          SurveillanceSystem = new Watch_Service();
          progressbar = progressbar + .1;
          splashWindow.SetProgress(progressbar);
  
          Start_Watch_Service(this);
          progressbar = progressbar + .1;
          splashWindow.SetProgress(progressbar);
  
          splashWindow.SetProgress(1);
  
          // Create the main window, but on the UI thread.
          Dispatcher.BeginInvoke(DispatcherPriority.Normal, (Invoker)delegate
          {
              mainwindow = new MainWindow();
              mainwindow.Show();
  
          });
      }
  </code></pre>
  
  <p>Further, this is the Watch Service Code, which checks the web every 2 hours:</p>
  
  <pre><code>    private async Task Start_Watch_Service(IpSumApp CheckApp)
      {
              while (CheckApp._contentLoaded == true)
              {
  
                  SurveillanceSystem.DOF_Links = await SurveillanceSystem.Watch_DOF("www.emol.com");
                  double CheckWaitTime = 2*60;
                  Thread.Sleep(60 * Convert.ToInt32(Math.Round(1000 * CheckWaitTime)));
              }
      }
  </code></pre>
  
  <p>I have tried the app. When there is the desired data in the webpage (a PDF), it dowloads it and performs a slow operation and continues. Eventually, the Mainwindow shows up.
  However, when there is nothing, the load stops at the line</p>
  
  <pre><code>Thread.Sleep(60 * Convert.ToInt32(Math.Round(1000 * CheckWaitTime)))
  </code></pre>