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
屬性值
以秒為單位的交易逾時。
範例
下列程式代碼範例會取得並設定 Transaction
屬性的 Timeout 屬性值。
[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