Home All Groups Group Topic Archive Search About

System.Transactions DependentClone with COM+

Author
29 Mar 2006 10:07 AM
Dave
Hi,

I'm using System.Transactions and want to call two separate existing COM+
components on separate threads so they do their updates using the
DependentClone functionality in System.Transactions, code snippets as follows:

using (TransactionScope scope = new
TransactionScope(TransactionScopeOption.Required,
transOptions,EnterpriseServicesInteropOption.Full  ))
{
  // Note, without using Full above the following COM+ component doesn't
enlist
  Call existing COM+ Component

  // Now queue a new thread
  ThreadPool.QueueUserWorkItem(new WaitCallback(WorkerThread),  
Transaction.Current.DependentClone(DependentCloneOption.BlockCommitUntilComplete));

}

// This is the worker thread

private static void WorkerThread(object transaction)
{
    //Create a DependentTransaction from the object passed to the WorkerThread
    DependentTransaction dTx = (DependentTransaction)transaction;

    //Sleep for 1 second to force the worker thread to delay
    Thread.Sleep(1000);

    //Pass the DependentTransaction to the scope, so that work done in the
scope becomes part of the transaction passed to the worker thread
            using (TransactionScope ts = new TransactionScope(dTx,
TimeSpan.FromSeconds(20), EnterpriseServicesInteropOption.Full))
    {
        Call another COM+ component

        //Call complete on the transaction scope
        ts.Complete();
    }

    //Call complete on the dependent transaction
    dTx.Complete();
}

When I run this, I get this error from the new thread:

"Distributed transaction completed. Either enlist this session in a new
transaction or the NULL transaction"

So, my question is whether or not I can use DependentTransaction with
existing COM+ components?

Thanks,
Dave

AddThis Social Bookmark Button