TransactionAttribute.Timeout 属性
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取或设置该事务的超时。
public:
property int Timeout { int get(); void set(int value); };
public int Timeout { get; set; }
member this.Timeout : int with get, set
Public Property Timeout As Integer
属性值
以秒为单位的事务超时。
示例
下面的代码示例获取并设置特性的 Timeout 属性的值Transaction
。
[Transaction(Timeout=30)]
public class TransactionAttribute_Timeout : ServicedComponent
{
public void TimeoutExample()
{
// Get the TransactionAttribute applied to the class.
TransactionAttribute attribute =
(TransactionAttribute)Attribute.GetCustomAttribute(
this.GetType(),
typeof(TransactionAttribute),
false);
// Display the current value of the attribute's Timeout property.
Console.WriteLine("TransactionAttribute.Timeout: {0}",
attribute.Timeout);
// Set the Timeout property value of the attribute to sixty
// seconds.
attribute.Timeout = 60;
// Display the new value of the attribute's Timeout property.
Console.WriteLine("TransactionAttribute.Timeout: {0}",
attribute.Timeout);
}
}
<Transaction(Timeout := 30)> _
Public Class TransactionAttribute_Timeout
Inherits ServicedComponent
Public Sub TimeoutExample()
' Get the TransactionAttribute applied to the class.
Dim attribute As TransactionAttribute = CType(Attribute.GetCustomAttribute(Me.GetType(), GetType(TransactionAttribute), False), TransactionAttribute)
' Display the current value of the attribute's Timeout property.
MsgBox("TransactionAttribute.Timeout: " & attribute.Timeout)
' Set the Timeout property value of the attribute to sixty
' seconds.
attribute.Timeout = 60
' Display the new value of the attribute's Timeout property.
MsgBox("TransactionAttribute.Timeout: " & attribute.Timeout)
End Sub
End Class