TransactionScope 构造函数

定义

初始化 TransactionScope 类的新实例。Initializes a new instance of the TransactionScope class.

重载

TransactionScope()

初始化 TransactionScope 类的新实例。Initializes a new instance of the TransactionScope class.

TransactionScope(Transaction)

初始化 TransactionScope 类的新实例,并将指定的事务设置为环境事务,以便该范围中进行的事务性工作使用此事务。Initializes a new instance of the TransactionScope class and sets the specified transaction as the ambient transaction, so that transactional work done inside the scope uses this transaction.

TransactionScope(Transaction, TransactionScopeAsyncFlowOption)

[在 .NET Framework 4.5.1 和更高版本中受支持][Supported in the .NET Framework 4.5.1 and later versions] 初始化 TransactionScope 类的新实例,并将指定的事务设置为环境事务,以便该范围中进行的事务性工作使用此事务。Initializes a new instance of the TransactionScope class and sets the specified transaction as the ambient transaction, so that transactional work done inside the scope uses this transaction.

TransactionScope(TransactionScopeAsyncFlowOption)

使用指定的异步流选项初始化 TransactionScope 类的新实例。Initializes a new instance of the TransactionScope class with the specified asynchronous flow option.

TransactionScope(TransactionScopeOption)

以指定的要求初始化 TransactionScope 类的新实例。Initializes a new instance of the TransactionScope class with the specified requirements.

TransactionScope(Transaction, TimeSpan, TransactionScopeAsyncFlowOption)

[在 .NET Framework 4.5.1 和更高版本中受支持][Supported in the .NET Framework 4.5.1 and later versions] 使用指定的超时时间值初始化 TransactionScope 类的新实例,并将指定的事务设置为环境事务,以便该范围中进行的事务性工作使用此事务。Initializes a new instance of the TransactionScope class with the specified timeout value, and sets the specified transaction as the ambient transaction, so that transactional work done inside the scope uses this transaction.

TransactionScope(TransactionScopeOption, TransactionOptions)

以指定的要求初始化 TransactionScope 类的新实例。Initializes a new instance of the TransactionScope class with the specified requirements.

TransactionScope(TransactionScopeOption, TransactionOptions, TransactionScopeAsyncFlowOption)

[在 .NET Framework 4.5.1 和更高版本中受支持][Supported in the .NET Framework 4.5.1 and later versions] 以指定的要求和异步流选项初始化 TransactionScope 类的新实例。Initializes a new instance of the TransactionScope class with the specified requirements and asynchronous flow option.

TransactionScope(Transaction, TimeSpan)

使用指定的超时时间值初始化 TransactionScope 类的新实例,并将指定的事务设置为环境事务,以便该范围中进行的事务性工作使用此事务。Initializes a new instance of the TransactionScope class with the specified timeout value, and sets the specified transaction as the ambient transaction, so that transactional work done inside the scope uses this transaction.

TransactionScope(TransactionScopeOption, TimeSpan)

以指定的超时时间值和要求初始化 TransactionScope 类的新实例。Initializes a new instance of the TransactionScope class with the specified timeout value and requirements.

TransactionScope(TransactionScopeOption, TransactionScopeAsyncFlowOption)

以指定的要求和异步流选项初始化 TransactionScope 类的新实例。Initializes a new instance of the TransactionScope class with the specified requirements and asynchronous flow option.

TransactionScope(TransactionScopeOption, TransactionOptions, EnterpriseServicesInteropOption)

使用指定的范围和 COM+ 互操作性要求以及事务选项初始化 TransactionScope 类的新实例。Initializes a new instance of the TransactionScope class with the specified scope and COM+ interoperability requirements, and transaction options.

TransactionScope(Transaction, TimeSpan, EnterpriseServicesInteropOption)

使用指定的超时时间值和 COM+ 互操作性要求初始化 TransactionScope 类的新实例,并将指定的事务设置为环境事务,以便该范围中进行的事务性工作使用此事务。Initializes a new instance of the TransactionScope class with the specified timeout value and COM+ interoperability requirements, and sets the specified transaction as the ambient transaction, so that transactional work done inside the scope uses this transaction.

TransactionScope(TransactionScopeOption, TimeSpan, TransactionScopeAsyncFlowOption)

以指定的超时值、要求和异步流选项初始化 TransactionScope 类的新实例。Initializes a new instance of the TransactionScope class with the specified timeout value, requirements, and asynchronous flow option.

TransactionScope()

初始化 TransactionScope 类的新实例。Initializes a new instance of the TransactionScope class.

public:
 TransactionScope();
public TransactionScope ();
Public Sub New ()

注解

此构造函数将创建一个新的事务作用域,其中的事务作用域选项等于 RequiredThis constructor creates a new transaction scope with the transaction scope option equal to Required. 这意味着新的作用域需要事务,并且如果已存在环境事务,则使用该环境事务。This means that a transaction is required by the new scope and the ambient transaction is used if one already exists. 否则,在进入范围之前创建新的事务。Otherwise, it creates a new transaction before entering the scope.

适用于

TransactionScope(Transaction)

初始化 TransactionScope 类的新实例,并将指定的事务设置为环境事务,以便该范围中进行的事务性工作使用此事务。Initializes a new instance of the TransactionScope class and sets the specified transaction as the ambient transaction, so that transactional work done inside the scope uses this transaction.

public:
 TransactionScope(System::Transactions::Transaction ^ transactionToUse);
public:
 TransactionScope(System::Transactions::Transaction ^ transaction);
public TransactionScope (System.Transactions.Transaction transactionToUse);
public TransactionScope (System.Transactions.Transaction transaction);
new System.Transactions.TransactionScope : System.Transactions.Transaction -> System.Transactions.TransactionScope
new System.Transactions.TransactionScope : System.Transactions.Transaction -> System.Transactions.TransactionScope
Public Sub New (transactionToUse As Transaction)
Public Sub New (transaction As Transaction)

参数

transactionToUsetransaction
Transaction

要设置为环境事务(以便该范围中进行的事务性工作使用此事务)的事务。The transaction to be set as the ambient transaction, so that transactional work done inside the scope uses this transaction.

适用于

TransactionScope(Transaction, TransactionScopeAsyncFlowOption)

[在 .NET Framework 4.5.1 和更高版本中受支持][Supported in the .NET Framework 4.5.1 and later versions] 初始化 TransactionScope 类的新实例,并将指定的事务设置为环境事务,以便该范围中进行的事务性工作使用此事务。Initializes a new instance of the TransactionScope class and sets the specified transaction as the ambient transaction, so that transactional work done inside the scope uses this transaction.

public:
 TransactionScope(System::Transactions::Transaction ^ transactionToUse, System::Transactions::TransactionScopeAsyncFlowOption asyncFlowOption);
public TransactionScope (System.Transactions.Transaction transactionToUse, System.Transactions.TransactionScopeAsyncFlowOption asyncFlowOption);
new System.Transactions.TransactionScope : System.Transactions.Transaction * System.Transactions.TransactionScopeAsyncFlowOption -> System.Transactions.TransactionScope
Public Sub New (transactionToUse As Transaction, asyncFlowOption As TransactionScopeAsyncFlowOption)

参数

transactionToUse
Transaction

要设置为环境事务(以便该范围中进行的事务性工作使用此事务)的事务。The transaction to be set as the ambient transaction, so that transactional work done inside the scope uses this transaction.

asyncFlowOption
TransactionScopeAsyncFlowOption

TransactionScopeAsyncFlowOption 枚举的实例,描述了当使用 Task 或 async/await .NET 异步编程模式时,与事务范围关联的环境事务将跨线程连续任务执行。An instance of the TransactionScopeAsyncFlowOption enumeration that describes whether the ambient transaction associated with the transaction scope will flow across thread continuations when using Task or async/await .NET async programming patterns.

适用于

TransactionScope(TransactionScopeAsyncFlowOption)

使用指定的异步流选项初始化 TransactionScope 类的新实例。Initializes a new instance of the TransactionScope class with the specified asynchronous flow option.

public:
 TransactionScope(System::Transactions::TransactionScopeAsyncFlowOption asyncFlowOption);
public:
 TransactionScope(System::Transactions::TransactionScopeAsyncFlowOption asyncFlow);
public TransactionScope (System.Transactions.TransactionScopeAsyncFlowOption asyncFlowOption);
public TransactionScope (System.Transactions.TransactionScopeAsyncFlowOption asyncFlow);
new System.Transactions.TransactionScope : System.Transactions.TransactionScopeAsyncFlowOption -> System.Transactions.TransactionScope
new System.Transactions.TransactionScope : System.Transactions.TransactionScopeAsyncFlowOption -> System.Transactions.TransactionScope
Public Sub New (asyncFlowOption As TransactionScopeAsyncFlowOption)
Public Sub New (asyncFlow As TransactionScopeAsyncFlowOption)

参数

asyncFlowOptionasyncFlow
TransactionScopeAsyncFlowOption

TransactionScopeAsyncFlowOption 枚举的实例,描述了当使用 Task 或 async/await .NET 异步编程模式时,与事务范围关联的环境事务将跨线程连续任务执行。An instance of the TransactionScopeAsyncFlowOption enumeration that describes whether the ambient transaction associated with the transaction scope will flow across thread continuations when using Task or async/await .NET async programming patterns.

适用于

TransactionScope(TransactionScopeOption)

以指定的要求初始化 TransactionScope 类的新实例。Initializes a new instance of the TransactionScope class with the specified requirements.

public:
 TransactionScope(System::Transactions::TransactionScopeOption scopeOption);
public:
 TransactionScope(System::Transactions::TransactionScopeOption option);
public TransactionScope (System.Transactions.TransactionScopeOption scopeOption);
public TransactionScope (System.Transactions.TransactionScopeOption option);
new System.Transactions.TransactionScope : System.Transactions.TransactionScopeOption -> System.Transactions.TransactionScope
new System.Transactions.TransactionScope : System.Transactions.TransactionScopeOption -> System.Transactions.TransactionScope
Public Sub New (scopeOption As TransactionScopeOption)
Public Sub New (option As TransactionScopeOption)

参数

scopeOptionoption
TransactionScopeOption

TransactionScopeOption 枚举的实例,描述与此事务范围关联的事务要求。An instance of the TransactionScopeOption enumeration that describes the transaction requirements associated with this transaction scope.

适用于

TransactionScope(Transaction, TimeSpan, TransactionScopeAsyncFlowOption)

[在 .NET Framework 4.5.1 和更高版本中受支持][Supported in the .NET Framework 4.5.1 and later versions] 使用指定的超时时间值初始化 TransactionScope 类的新实例,并将指定的事务设置为环境事务,以便该范围中进行的事务性工作使用此事务。Initializes a new instance of the TransactionScope class with the specified timeout value, and sets the specified transaction as the ambient transaction, so that transactional work done inside the scope uses this transaction.

public:
 TransactionScope(System::Transactions::Transaction ^ transactionToUse, TimeSpan scopeTimeout, System::Transactions::TransactionScopeAsyncFlowOption asyncFlowOption);
public TransactionScope (System.Transactions.Transaction transactionToUse, TimeSpan scopeTimeout, System.Transactions.TransactionScopeAsyncFlowOption asyncFlowOption);
new System.Transactions.TransactionScope : System.Transactions.Transaction * TimeSpan * System.Transactions.TransactionScopeAsyncFlowOption -> System.Transactions.TransactionScope
Public Sub New (transactionToUse As Transaction, scopeTimeout As TimeSpan, asyncFlowOption As TransactionScopeAsyncFlowOption)

参数

transactionToUse
Transaction

要设置为环境事务(以便该范围中进行的事务性工作使用此事务)的事务。The transaction to be set as the ambient transaction, so that transactional work done inside the scope uses this transaction.

scopeTimeout
TimeSpan

TimeSpan 之后,事务范围将超时并中止此事务。The TimeSpan after which the transaction scope times out and aborts the transaction.

asyncFlowOption
TransactionScopeAsyncFlowOption

TransactionScopeAsyncFlowOption 枚举的实例,描述了当使用 Task 或 async/await .NET 异步编程模式时,与事务范围关联的环境事务将跨线程连续任务执行。An instance of the TransactionScopeAsyncFlowOption enumeration that describes whether the ambient transaction associated with the transaction scope will flow across thread continuations when using Task or async/await .NET async programming patterns.

适用于

TransactionScope(TransactionScopeOption, TransactionOptions)

以指定的要求初始化 TransactionScope 类的新实例。Initializes a new instance of the TransactionScope class with the specified requirements.

public:
 TransactionScope(System::Transactions::TransactionScopeOption scopeOption, System::Transactions::TransactionOptions transactionOptions);
public:
 TransactionScope(System::Transactions::TransactionScopeOption scopeOption, System::Transactions::TransactionOptions options);
public TransactionScope (System.Transactions.TransactionScopeOption scopeOption, System.Transactions.TransactionOptions transactionOptions);
public TransactionScope (System.Transactions.TransactionScopeOption scopeOption, System.Transactions.TransactionOptions options);
new System.Transactions.TransactionScope : System.Transactions.TransactionScopeOption * System.Transactions.TransactionOptions -> System.Transactions.TransactionScope
new System.Transactions.TransactionScope : System.Transactions.TransactionScopeOption * System.Transactions.TransactionOptions -> System.Transactions.TransactionScope
Public Sub New (scopeOption As TransactionScopeOption, transactionOptions As TransactionOptions)
Public Sub New (scopeOption As TransactionScopeOption, options As TransactionOptions)

参数

scopeOption
TransactionScopeOption

TransactionScopeOption 枚举的实例,描述与此事务范围关联的事务要求。An instance of the TransactionScopeOption enumeration that describes the transaction requirements associated with this transaction scope.

transactionOptionsoptions
TransactionOptions

TransactionOptions 结构描述要在创建新事务时使用的事务选项。A TransactionOptions structure that describes the transaction options to use if a new transaction is created. 如果使用现有的事务,则此参数中的超时值将应用于该事务范围。If an existing transaction is used, the timeout value in this parameter applies to the transaction scope. 如果该时间在范围被释放之前到期,则事务将中止。If that time expires before the scope is disposed, the transaction is aborted.

注解

如果使用 transactionOptions 参数指定 IsolationLevel ,并且作用域稍后会创建事务,则新事务将与指定的隔离级别关联。When you use the transactionOptions parameter to specify an IsolationLevel, and the scope creates a transaction later, the new transaction is associated with the specified isolation level. 如果隔离级别与事务一起传入,则事务必须具有相同的隔离级别,否则会引发异常。If an isolation level is passed in together with a transaction, the transaction must have an identical isolation level, or an exception is thrown.

适用于

TransactionScope(TransactionScopeOption, TransactionOptions, TransactionScopeAsyncFlowOption)

[在 .NET Framework 4.5.1 和更高版本中受支持][Supported in the .NET Framework 4.5.1 and later versions] 以指定的要求和异步流选项初始化 TransactionScope 类的新实例。Initializes a new instance of the TransactionScope class with the specified requirements and asynchronous flow option.

public:
 TransactionScope(System::Transactions::TransactionScopeOption scopeOption, System::Transactions::TransactionOptions transactionOptions, System::Transactions::TransactionScopeAsyncFlowOption asyncFlowOption);
public TransactionScope (System.Transactions.TransactionScopeOption scopeOption, System.Transactions.TransactionOptions transactionOptions, System.Transactions.TransactionScopeAsyncFlowOption asyncFlowOption);
new System.Transactions.TransactionScope : System.Transactions.TransactionScopeOption * System.Transactions.TransactionOptions * System.Transactions.TransactionScopeAsyncFlowOption -> System.Transactions.TransactionScope
Public Sub New (scopeOption As TransactionScopeOption, transactionOptions As TransactionOptions, asyncFlowOption As TransactionScopeAsyncFlowOption)

参数

scopeOption
TransactionScopeOption

TransactionScopeOption 枚举的实例,描述与此事务范围关联的事务要求。An instance of the TransactionScopeOption enumeration that describes the transaction requirements associated with this transaction scope.

transactionOptions
TransactionOptions

TransactionOptions 结构描述要在创建新事务时使用的事务选项。A TransactionOptions structure that describes the transaction options to use if a new transaction is created. 如果使用现有的事务,则此参数中的超时值将应用于该事务范围。If an existing transaction is used, the timeout value in this parameter applies to the transaction scope. 如果该时间在范围被释放之前到期,则事务将中止。If that time expires before the scope is disposed, the transaction is aborted.

asyncFlowOption
TransactionScopeAsyncFlowOption

TransactionScopeAsyncFlowOption 枚举的实例,描述了当使用 Task 或 async/await .NET 异步编程模式时,与事务范围关联的环境事务将跨线程连续任务执行。An instance of the TransactionScopeAsyncFlowOption enumeration that describes whether the ambient transaction associated with the transaction scope will flow across thread continuations when using Task or async/await .NET async programming patterns.

适用于

TransactionScope(Transaction, TimeSpan)

使用指定的超时时间值初始化 TransactionScope 类的新实例,并将指定的事务设置为环境事务,以便该范围中进行的事务性工作使用此事务。Initializes a new instance of the TransactionScope class with the specified timeout value, and sets the specified transaction as the ambient transaction, so that transactional work done inside the scope uses this transaction.

public:
 TransactionScope(System::Transactions::Transaction ^ transactionToUse, TimeSpan scopeTimeout);
public:
 TransactionScope(System::Transactions::Transaction ^ transaction, TimeSpan timeout);
public TransactionScope (System.Transactions.Transaction transactionToUse, TimeSpan scopeTimeout);
public TransactionScope (System.Transactions.Transaction transaction, TimeSpan timeout);
new System.Transactions.TransactionScope : System.Transactions.Transaction * TimeSpan -> System.Transactions.TransactionScope
new System.Transactions.TransactionScope : System.Transactions.Transaction * TimeSpan -> System.Transactions.TransactionScope
Public Sub New (transactionToUse As Transaction, scopeTimeout As TimeSpan)
Public Sub New (transaction As Transaction, timeout As TimeSpan)

参数

transactionToUsetransaction
Transaction

要设置为环境事务(以便该范围中进行的事务性工作使用此事务)的事务。The transaction to be set as the ambient transaction, so that transactional work done inside the scope uses this transaction.

scopeTimeouttimeout
TimeSpan

TimeSpan 之后,事务范围将超时并中止此事务。The TimeSpan after which the transaction scope times out and aborts the transaction.

适用于

TransactionScope(TransactionScopeOption, TimeSpan)

以指定的超时时间值和要求初始化 TransactionScope 类的新实例。Initializes a new instance of the TransactionScope class with the specified timeout value and requirements.

public:
 TransactionScope(System::Transactions::TransactionScopeOption scopeOption, TimeSpan scopeTimeout);
public:
 TransactionScope(System::Transactions::TransactionScopeOption option, TimeSpan timeout);
public TransactionScope (System.Transactions.TransactionScopeOption scopeOption, TimeSpan scopeTimeout);
public TransactionScope (System.Transactions.TransactionScopeOption option, TimeSpan timeout);
new System.Transactions.TransactionScope : System.Transactions.TransactionScopeOption * TimeSpan -> System.Transactions.TransactionScope
new System.Transactions.TransactionScope : System.Transactions.TransactionScopeOption * TimeSpan -> System.Transactions.TransactionScope
Public Sub New (scopeOption As TransactionScopeOption, scopeTimeout As TimeSpan)
Public Sub New (option As TransactionScopeOption, timeout As TimeSpan)

参数

scopeOptionoption
TransactionScopeOption

TransactionScopeOption 枚举的实例,描述与此事务范围关联的事务要求。An instance of the TransactionScopeOption enumeration that describes the transaction requirements associated with this transaction scope.

scopeTimeouttimeout
TimeSpan

TimeSpan 之后,事务范围将超时并中止此事务。The TimeSpan after which the transaction scope times out and aborts the transaction.

适用于

TransactionScope(TransactionScopeOption, TransactionScopeAsyncFlowOption)

以指定的要求和异步流选项初始化 TransactionScope 类的新实例。Initializes a new instance of the TransactionScope class with the specified requirements and asynchronous flow option.

public:
 TransactionScope(System::Transactions::TransactionScopeOption scopeOption, System::Transactions::TransactionScopeAsyncFlowOption asyncFlowOption);
public:
 TransactionScope(System::Transactions::TransactionScopeOption option, System::Transactions::TransactionScopeAsyncFlowOption asyncFlow);
public TransactionScope (System.Transactions.TransactionScopeOption scopeOption, System.Transactions.TransactionScopeAsyncFlowOption asyncFlowOption);
public TransactionScope (System.Transactions.TransactionScopeOption option, System.Transactions.TransactionScopeAsyncFlowOption asyncFlow);
new System.Transactions.TransactionScope : System.Transactions.TransactionScopeOption * System.Transactions.TransactionScopeAsyncFlowOption -> System.Transactions.TransactionScope
new System.Transactions.TransactionScope : System.Transactions.TransactionScopeOption * System.Transactions.TransactionScopeAsyncFlowOption -> System.Transactions.TransactionScope
Public Sub New (scopeOption As TransactionScopeOption, asyncFlowOption As TransactionScopeAsyncFlowOption)
Public Sub New (option As TransactionScopeOption, asyncFlow As TransactionScopeAsyncFlowOption)

参数

scopeOptionoption
TransactionScopeOption

TransactionScopeOption 枚举的实例,描述与此事务范围关联的事务要求。An instance of the TransactionScopeOption enumeration that describes the transaction requirements associated with this transaction scope.

asyncFlowOptionasyncFlow
TransactionScopeAsyncFlowOption

TransactionScopeAsyncFlowOption 枚举的实例,描述了当使用 Task 或 async/await .NET 异步编程模式时,与事务范围关联的环境事务将跨线程连续任务执行。An instance of the TransactionScopeAsyncFlowOption enumeration that describes whether the ambient transaction associated with the transaction scope will flow across thread continuations when using Task or async/await .NET async programming patterns.

适用于

TransactionScope(TransactionScopeOption, TransactionOptions, EnterpriseServicesInteropOption)

使用指定的范围和 COM+ 互操作性要求以及事务选项初始化 TransactionScope 类的新实例。Initializes a new instance of the TransactionScope class with the specified scope and COM+ interoperability requirements, and transaction options.

public:
 TransactionScope(System::Transactions::TransactionScopeOption scopeOption, System::Transactions::TransactionOptions transactionOptions, System::Transactions::EnterpriseServicesInteropOption interopOption);
public:
 TransactionScope(System::Transactions::TransactionScopeOption scopeOption, System::Transactions::TransactionOptions options, System::Transactions::EnterpriseServicesInteropOption opt);
public TransactionScope (System.Transactions.TransactionScopeOption scopeOption, System.Transactions.TransactionOptions transactionOptions, System.Transactions.EnterpriseServicesInteropOption interopOption);
public TransactionScope (System.Transactions.TransactionScopeOption scopeOption, System.Transactions.TransactionOptions options, System.Transactions.EnterpriseServicesInteropOption opt);
new System.Transactions.TransactionScope : System.Transactions.TransactionScopeOption * System.Transactions.TransactionOptions * System.Transactions.EnterpriseServicesInteropOption -> System.Transactions.TransactionScope
new System.Transactions.TransactionScope : System.Transactions.TransactionScopeOption * System.Transactions.TransactionOptions * System.Transactions.EnterpriseServicesInteropOption -> System.Transactions.TransactionScope
Public Sub New (scopeOption As TransactionScopeOption, transactionOptions As TransactionOptions, interopOption As EnterpriseServicesInteropOption)
Public Sub New (scopeOption As TransactionScopeOption, options As TransactionOptions, opt As EnterpriseServicesInteropOption)

参数

scopeOption
TransactionScopeOption

TransactionScopeOption 枚举的实例,描述与此事务范围关联的事务要求。An instance of the TransactionScopeOption enumeration that describes the transaction requirements associated with this transaction scope.

transactionOptionsoptions
TransactionOptions

TransactionOptions 结构描述要在创建新事务时使用的事务选项。A TransactionOptions structure that describes the transaction options to use if a new transaction is created. 如果使用现有的事务,则此参数中的超时值将应用于该事务范围。If an existing transaction is used, the timeout value in this parameter applies to the transaction scope. 如果该时间在范围被释放之前到期,则事务将中止。If that time expires before the scope is disposed, the transaction is aborted.

interopOptionopt
EnterpriseServicesInteropOption

EnterpriseServicesInteropOption 枚举的一个实例,用于说明关联的事务如何与 COM+ 事务进行交互。An instance of the EnterpriseServicesInteropOption enumeration that describes how the associated transaction interacts with COM+ transactions.

注解

如果使用 transactionOptions 参数指定 IsolationLevel ,并且作用域稍后会创建事务,则新事务将与指定的隔离级别关联。When you use the transactionOptions parameter to specify an IsolationLevel, and the scope creates a transaction later, the new transaction is associated with the specified isolation level. 如果隔离级别与事务一起传入,则事务必须具有相同的隔离级别,否则会引发异常。If an isolation level is passed in together with a transaction, the transaction must have an identical isolation level, or an exception is thrown.

注意 此方法使用 LinkDemand 来防止不受信任的代码调用; 但是,只有直接调用方才能拥有 FullTrust 权限集。Note This method uses LinkDemand to prevent it from being called from untrusted code; however, only the immediate caller is required to possess the FullTrust permission set.

适用于

TransactionScope(Transaction, TimeSpan, EnterpriseServicesInteropOption)

使用指定的超时时间值和 COM+ 互操作性要求初始化 TransactionScope 类的新实例,并将指定的事务设置为环境事务,以便该范围中进行的事务性工作使用此事务。Initializes a new instance of the TransactionScope class with the specified timeout value and COM+ interoperability requirements, and sets the specified transaction as the ambient transaction, so that transactional work done inside the scope uses this transaction.

public:
 TransactionScope(System::Transactions::Transaction ^ transactionToUse, TimeSpan scopeTimeout, System::Transactions::EnterpriseServicesInteropOption interopOption);
public:
 TransactionScope(System::Transactions::Transaction ^ transaction, TimeSpan timeout, System::Transactions::EnterpriseServicesInteropOption opt);
public TransactionScope (System.Transactions.Transaction transactionToUse, TimeSpan scopeTimeout, System.Transactions.EnterpriseServicesInteropOption interopOption);
public TransactionScope (System.Transactions.Transaction transaction, TimeSpan timeout, System.Transactions.EnterpriseServicesInteropOption opt);
new System.Transactions.TransactionScope : System.Transactions.Transaction * TimeSpan * System.Transactions.EnterpriseServicesInteropOption -> System.Transactions.TransactionScope
new System.Transactions.TransactionScope : System.Transactions.Transaction * TimeSpan * System.Transactions.EnterpriseServicesInteropOption -> System.Transactions.TransactionScope
Public Sub New (transactionToUse As Transaction, scopeTimeout As TimeSpan, interopOption As EnterpriseServicesInteropOption)
Public Sub New (transaction As Transaction, timeout As TimeSpan, opt As EnterpriseServicesInteropOption)

参数

transactionToUsetransaction
Transaction

要设置为环境事务(以便该范围中进行的事务性工作使用此事务)的事务。The transaction to be set as the ambient transaction, so that transactional work done inside the scope uses this transaction.

scopeTimeouttimeout
TimeSpan

TimeSpan 之后,事务范围将超时并中止此事务。The TimeSpan after which the transaction scope times out and aborts the transaction.

interopOptionopt
EnterpriseServicesInteropOption

EnterpriseServicesInteropOption 枚举的一个实例,用于说明关联的事务如何与 COM+ 事务进行交互。An instance of the EnterpriseServicesInteropOption enumeration that describes how the associated transaction interacts with COM+ transactions.

注解

注意 此方法使用 LinkDemand 来防止不受信任的代码调用; 但是,只有直接调用方才能拥有 FullTrust 权限集。Note This method uses LinkDemand to prevent it from being called from untrusted code; however, only the immediate caller is required to possess the FullTrust permission set.

适用于

TransactionScope(TransactionScopeOption, TimeSpan, TransactionScopeAsyncFlowOption)

以指定的超时值、要求和异步流选项初始化 TransactionScope 类的新实例。Initializes a new instance of the TransactionScope class with the specified timeout value, requirements, and asynchronous flow option.

public:
 TransactionScope(System::Transactions::TransactionScopeOption scopeOption, TimeSpan scopeTimeout, System::Transactions::TransactionScopeAsyncFlowOption asyncFlowOption);
public:
 TransactionScope(System::Transactions::TransactionScopeOption option, TimeSpan timeout, System::Transactions::TransactionScopeAsyncFlowOption asyncFlow);
public TransactionScope (System.Transactions.TransactionScopeOption scopeOption, TimeSpan scopeTimeout, System.Transactions.TransactionScopeAsyncFlowOption asyncFlowOption);
public TransactionScope (System.Transactions.TransactionScopeOption option, TimeSpan timeout, System.Transactions.TransactionScopeAsyncFlowOption asyncFlow);
new System.Transactions.TransactionScope : System.Transactions.TransactionScopeOption * TimeSpan * System.Transactions.TransactionScopeAsyncFlowOption -> System.Transactions.TransactionScope
new System.Transactions.TransactionScope : System.Transactions.TransactionScopeOption * TimeSpan * System.Transactions.TransactionScopeAsyncFlowOption -> System.Transactions.TransactionScope
Public Sub New (scopeOption As TransactionScopeOption, scopeTimeout As TimeSpan, asyncFlowOption As TransactionScopeAsyncFlowOption)
Public Sub New (option As TransactionScopeOption, timeout As TimeSpan, asyncFlow As TransactionScopeAsyncFlowOption)

参数

scopeOptionoption
TransactionScopeOption

TransactionScopeOption 枚举的实例,描述与此事务范围关联的事务要求。An instance of the TransactionScopeOption enumeration that describes the transaction requirements associated with this transaction scope.

scopeTimeouttimeout
TimeSpan

TimeSpan 之后,事务范围将超时并中止此事务。The TimeSpan after which the transaction scope times out and aborts the transaction.

asyncFlowOptionasyncFlow
TransactionScopeAsyncFlowOption

TransactionScopeAsyncFlowOption 枚举的实例,描述了当使用 Task 或 async/await .NET 异步编程模式时,与事务范围关联的环境事务将跨线程连续任务执行。An instance of the TransactionScopeAsyncFlowOption enumeration that describes whether the ambient transaction associated with the transaction scope will flow across thread continuations when using Task or async/await .NET async programming patterns.

适用于