2011-02-25 54 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

回答

相關問題