开发者

TransactionScope: How do I Read back the results of a committed transaction?

开发者 https://www.devze.com 2023-03-03 14:17 出处:网络
I want to do work in a distributed transaction, commit it, then be able to read the results. Something like:

I want to do work in a distributed transaction, commit it, then be able to read the results. Something like:

using( var ts = new TransactionScope() )
{
do work on connection A
do work on connection B

ts.Complete();
}

read back work on A
read back work on B

This doesn't work consistently because the TransactionScope ends as soon as all the resource开发者_StackOverflow中文版s have said they will commit (start of phase 2), not that they have committed (end of phase 2) and the commits happen on a different thread.

Is there some way to force the commit to be synchronous? Or some other pattern I should be using to read back the results?


Normally, I would expect this to work, since you should be blocked until it is committed (or rolled back). Are you perhaps using lock-avoiding mechanisms (nolock etc)? You could always do the reads in another Serializable transaction (i.e. a second TransactionScope) - that should ensure the reads are true.

0

精彩评论

暂无评论...
验证码 换一张
取 消