title: Understanding transactionscope timeouts
body: <p>My current understanding of transactionscope timeouts. </p>
  
  <p>If a transaction has been running longer than the set timeout time it throws an exception when 
  transaction.complete() is called.  So if the processing within the transaction has been going on 
  for X minutes we still would have to wait X minutes after which the transaction.complete is called. </p>
  
  <p>In our case, we are using transactionscope from within a webservice - the end user of the web request
  will have to wait for X minutes before the transaction is aborted and the exception bubbled back. </p>
  
  <p>However, the default timeout for a HttpWebRequest is 100 seconds (according to msdn). Since the client times 
  out in 100 seconds we have a timeout in transactionscope of a minute. This ensures database consistency.  </p>
  
  <p>Is my understanding of timeouts correct? </p>
  
  <p>Question: We would like to minimize the time it takes for the end user to know the results of the transaction. To minimize latency we decided to split up the code using nested transactionscopes - each with a timeout of say 15 seconds. If a child transaction is taking longer than a 15 seconds we  abort the transaction as a whole. </p>
  
  <p>Here it seems that the child transaction's timeout is ignored. I get an exception only after the 
  parent transaction's timeout is called. In the following code ChildTransaction() always returns true. 
  What is the recommended approach to minimize the latency? <strong>The code shows default timeout of 1 minute just so the code is cleaner</strong></p>
  
  <pre><code>    internal bool RootTransaction()
      {           
          using (TransactionScope transaction = new TransactionScope())
          {
              try
              {
                  bool result = ChildTransaction();
  
                  //The result is always true. 
                  if (!result)
                      return result;                                     
  
                  for (int counter = 0;counter &lt;= 10;counter++)
                  {                       
                      //Either sleep OR do some processing 
                      System.Threading.Thread.Sleep(5000);
                      //
                      //Dosomeprocess()
                  }                    
                  transaction.Complete();                    
                  return true;
              }
              catch (Exception e)
              {                    
                  return false;
              }
          }                           
      }
  
      internal bool ChildTransaction()
      {            
          using (TransactionScope transaction = new TransactionScope())
          {
              try
              {
      //Sleep for 70 seconds
                  System.Threading.Thread.Sleep(70000);
                  transaction.Complete();                    
              }                
              catch (Exception e)
              {
                  return false;
              }                
          }
          return true;
      }
  </code></pre>