2011-02-25 56 views
0

1)在以下示例客户端TransactionScope TS1超时。但是,除非TS1调用Complete()从而票提交事务,则不会抛出异常:为什么事务不会抛出TimeoutException?

TimeSpan timeout = TimeSpan.FromSeconds(2); 

using (TransactionScope scope1 = new TransactionScope(TransactionScopeOption.RequiresNew, timeout)) 
{ 
    proxy.GetAnimal(16); // returns after 10 seconds 
    Thread.Sleep(6000); 
} 

我意识到,如果没有调用完成()的交易将不会承诺,但我看不出为什么超时异常不该不管交易是否承诺,都不会被抛出?!

2)即使proxy.GetAnimal()在事务超时后调用,调用将仍然成功:

TimeSpan timeout = TimeSpan.FromSeconds(2); 
    using (TransactionScope scope1 = new TransactionScope(TransactionScopeOption.RequiresNew, timeout)) 
    { 
     proxy.GetAnimal(); // returns after 10 seconds 
     Thread.Sleep(6000); 
     proxy.GetAnimal(); // shouldn't this call cause an exception? 
    } 

会不会抛出更有意义的异常?

+0

可能重复(http://stackoverflow.com/questions/3344082/transactionscope-and-timeout-issue) – 2011-02-26 02:19:51

回答

相关问题