title: Exception when threading - propagation between threads?
body: <p><strong>If I have the following situation:</strong></p>
  
  <ol>
  <li>Execute() creates a new thread and executes function GetSession() in it.</li>
  <li>Execute() executes GetSession() again in it's own thread.</li>
  <li>Execute() joins the thread from (1).</li>
  </ol>
  
  <hr>
  
  <p><strong>My question is:</strong></p>
  
  <p>What happens if GetSession() throws an exception from the thread spawned in (1) while the thread Execute() is running in is currently running GetSession() itself?</p>
  
  <p>Does the exception re-thrown from the extra thread propagate up to Execute() and cause it to go to its handler <em>even though it's from a different thread?</em></p>
  
  <hr>
  
  <p><strong>Here's some sample code to demonstrate the issue:</strong></p>
  
  <p>I just made this up in the window here (it's a mock-up), so appologies for syntax errors.</p>
  
  <pre><code>public void Execute()
  {
      //Some logon data for two servers.
      string server1 = "x", server2 = "y", logon = "logon", password = "password";
  
      //Varialbes to store sessions in.
      MySession session1, session2;
  
      try
      {
          //Start first session request in new thread.
          Thread thread = new Thread(() =&gt;
              session1 = GetSession(server1, logon, password));
          thread.Start();
  
          //Start second request in current thread, wait for first to complete.
          session2 = GetSession(server2, logon, password));
          thread.Join();
      }
      catch(Exception ex)
      {
          //Will this get hit if thread1 throws an exception?
          MessageBox.Show(ex.ToString());
          return;
      }
  }
  
  private MySession GetSession(string server, string logon, string password)
  {
      try
      {
          return new MySession(server, logon, password);
      }
      catch(Exception Ex)
      {
          throw(Ex);
      }
  }
  </code></pre>