title: C# hang and stuck after Application.Run() at for loop
body: <p>Im building a program that surf to several websites and do something.</p>
  
  <p>After surfing to like 5 urls successfully, the program hangs after the Application.Run() line. 
  The program doesn't even enter the Handler function and just stuck. the CPU usage is 0 at this point.</p>
  
  <p>I tried closing the threads in any possible way.
  What i'm doing wrong?</p>
  
  <p>I'm doing it like that:</p>
  
  <pre><code>[STAThread]
  private static void Main(string[] args) 
  {
      for (int i = 0; i &lt; urls.Count; i++) 
      {
          var th = new Thread(() = &gt; 
          {
              var weBrowser = new WebBrowser();
              weBrowser.AllowNavigation = true;
              weBrowser.DocumentCompleted += Handler;
              weBrowser.Navigate(urls[i]);
              Application.Run();
          });
          th.SetApartmentState(ApartmentState.STA);
          th.Start();
          th.Join();
      }
  }
  </code></pre>
  
  <p>And my Handle function is:</p>
  
  <pre><code>private static void Handler(object sender, WebBrowserDocumentCompletedEventArgs e) 
  {
      WebBrowser weBrowser = sender as WebBrowser;
      var htmlDocument = weBrowser.Document;
  
      /*do something*/
  
      Application.Exit();
      Application.ExitThread();
  
      weBrowser.Dispose();
      weBrowser.Stop();
  
      Thread.CurrentThread.Abort();
  }
  </code></pre>
  
  <p>My problem is very similar to this one:
  <a href="https://stackoverflow.com/questions/4503812/application-run-leads-to-application-hanging">Application.Run() leads to application hanging</a></p>
  
  <p>There is no answer in this question either.</p>
  
  <p>Thanks!</p>