本文介绍了TransactionScope如何工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Method1()实例化一个 TransactionScope 并调用 Method2 c $ c>也实例化一个 TransactionScope ,.NET怎么知道两者在同一范围?
我相信它在内部不使用静态方法,否则它不能很好地在多线程应用程序如ASP.NET上工作。

When Method1() instantiates a TransactionScope and calls Method2() that also instantiates a TransactionScope, how does .NET know both are in the same scope?I believe it doesn't use static methods internally otherwise it wouldn't work well on multithreaded applications like ASP.NET.

是否可以创建我的

推荐答案

希望这有助于:

using(TransactionScope scope = new TransactionScope())
{
    ... // all operations here part of a transaction
    scope.Complete();
}


这篇关于TransactionScope如何工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-06 01:53