I am using:
public class TransactionUtils
{
public static TransactionScope CreateTransactionScope()
{
var TransactionOptions = new TransactionOptions();
TransactionOptions.IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted;
TransactionOptions.Timeout = TimeSpan.MaxValue;
return new TransactionScope(TransactionScopeOption.Required, TransactionOptions);
}
}
to create all my transactions. The problem I am facing is when I nest 2 TransactionUtils.CreateTransactionScope()
I get an error: Time-out interval must be less than 2^32-2. Parameter name: dueTm
. I am assuming this is because it's trying to attach the child transaction to the parent one and the combined timeouts are to large.
Is there a way to tell if a newly created transaction will be a nested one so I can avoid setting a timeout?
The alternative is to pass a parameter to CreateTransactionScope()
so I can tell it that's it's nested and not set the timeout but I would rather find an automatic way of handling it.
TimeSpan.MaxValue
part ? Maybe this would help #1964434 – Sufism