title: Sharing transaction scope between threads
body: <p>I have one class doing some transactional code.<br>
  Lets assume:  </p>
  
  <pre><code>class Worker
  {
      public void doWork()
      {
          //I do not want to create a new transaction. Instead, i want to use the environmenttransaction used by the caller of this method
          using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required))             {
              workItem1();
              workItem2();
              workItem3();
              scope.Complete();
          }
      }
  </code></pre>
  
  <p>Now i have some threads that execute this code:  </p>
  
  <pre><code>Worker worker = new Worker();
  using (TransactionScope transaction = new TransactionScope())
  {
      Thread Thread1 = new Thread(new ThreadStart(worker.doWork));
      Thread1.Start();
      Thread Thread2 = new Thread(new ThreadStart(worker.doWork));
      Thread2.Start();
      Thread Thread3 = new Thread(new ThreadStart(worker.doWork));
      Thread3.Start();
  
      Thread.Sleep(10000); //this should be enough to all the workers finish their job
  
      transaction.Complete();
  }  
  </code></pre>
  
  <p>Each thread is creating an own transaction. How do i do the share the same transaction between all threads?</p>