We know that TransactionScope class can use user-defined timeout value. But timeout exception is thrown while exiting from the using {} block. How to throw this timeoutexception immediately after elapsed timeout value?
相关问题
- Sorting 3 numbers without branching [closed]
- Graphics.DrawImage() - Throws out of memory except
- Why am I getting UnauthorizedAccessException on th
- 求获取指定qq 资料的方法
- How to know full paths to DLL's from .csproj f
This is not possible.
The TransactionScope simply stores the time that you started the transaction, then checks that time when committing the transaction.
It has no way to throw an exception at any arbitrary point.
In general, the only exception that can be thrown at any point in execution (of managed code) is
ThreadAbortException
.Therefore, if you really wanted to, you could make a separate thread that sleeps for the duration of the timeout, then aborts your original thread.
However, that's a horrible idea.