1) In the following example client-side TransactionScope TS1 timeouts. But unless TS1 calls Complete()
and thus votes to commit the transaction, no exception is thrown:
TimeSpan timeout = TimeSpan.FromSeconds(2);
using (TransactionScope scope1 = new TransactionScope(TransactionScopeOption.RequiresNew, timeout))
{
proxy.GetAnimal(16); // returns after 10 seconds
Thread.Sleep(6000);
}
I realize that without calling Complete() the transaction won’t get committed, but I fail to see why timeout exception shouldn’t be thrown regardless of whether transaction is committed or not?!
2) Even if proxy.GetAnimal()
is called after the transaction timeout, the call will still succeed:
TimeSpan timeout = TimeSpan.FromSeconds(2);
using (TransactionScope s开发者_StackOverflowcope1 = new TransactionScope(TransactionScopeOption.RequiresNew, timeout))
{
proxy.GetAnimal(); // returns after 10 seconds
Thread.Sleep(6000);
proxy.GetAnimal(); // shouldn't this call cause an exception?
}
Wouldn't throwing an exception made more sense?
See TransactionScope and Timeout Issue
精彩评论