TransactionScope.Timeout 属性

定义

获取或设置 TimeSpan,它指示用于此 TransactionScope 的事务的超时期限。

public:
 property System::Activities::InArgument<TimeSpan> ^ Timeout { System::Activities::InArgument<TimeSpan> ^ get(); void set(System::Activities::InArgument<TimeSpan> ^ value); };
public System.Activities.InArgument<TimeSpan> Timeout { get; set; }
member this.Timeout : System.Activities.InArgument<TimeSpan> with get, set
Public Property Timeout As InArgument(Of TimeSpan)

属性值

指示用于此 TimeSpan 的事务的超时期限的 TransactionScope

示例

下面的代码示例演示如何设置 TransactionScope 活动的 Timeout 属性。

new TransactionScope
{
    Body = new Sequence
    {
        Activities =
        {
            new WriteLine { Text = "    Begin TransactionScope" },

            new PrintTransactionId(),

            new TransactionScopeTest(),

            new WriteLine { Text = "    End TransactionScope" },
        },
    },
},

注解

此属性在运行时是只读的。 如果在运行时设置值, InvalidOperationException 则会引发 。

适用于