title: Unable to use TransactionScope with Tasks
body: <p>I am attempting to use TransactionScope across two queries to different SQL Server instances (the transaction is promoted to MSDTC). I have it working synchronously without using Tasks but am unable to get the transaction to rollback when using Tasks asynchronously. </p>
  
  <p>I have hidden both the connection strings to the servers and the update statements, but reast assured that they both connect and execute the SQL with no problems. I have intentionally set the SQL in the method <code>runTwo()</code> to fail and raise an exception. </p>
  
  <p>I am using .Net 4.5.2 which includes the enumeration <code>TransactionScopeAsyncFlowOption.Enabled</code> (in the TransactionScope constructor) that I believe should handle a transaction across threads but am unable to get this to work. </p>
  
  <pre><code>static void Main()
          {
              List&lt;Task&gt; tasks = new List&lt;Task&gt;();
              using (var scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled))
              {
                  try
                  {
                      tasks.Add(Task.Run(() =&gt; runOne()));
                      tasks.Add(Task.Run(() =&gt; runTwo()));
  
                      Task.WhenAll(tasks);
  
                      //Complete the scope
                      scope.Complete();
                  }
                  catch (Exception)
                  {
                      Transaction.Current.Rollback();
                  }
              }
              Console.ReadLine();
          }
  
          private static void runOne()
          {
              //Get the base SQL connection
              using (SqlConnection conn = new SqlConnection("Data Source=SERVER1....."))
              {
                  conn.Open();
  
                  SqlCommand command1 = new SqlCommand
                  {
                      CommandText = "Update .. Complete Successfully",
                      CommandType = CommandType.Text,
                      Connection = conn
                  };
  
                  command1.ExecuteNonQuery();
              }
          }
  
          private static void runTwo()
          {
              using (
                  SqlConnection conn =
                      new SqlConnection("Data Source=SERVER2...")
                  )
              {
                  conn.Open();
  
                  SqlCommand command2 = new SqlCommand
                  {
                      CommandText = "Update .... Raises Exception",
                      CommandType = CommandType.Text,
                      Connection = conn
                  };
  
                  //Execute the command
                  command2.ExecuteNonQuery();
  
              }
          }
  </code></pre>