ChannelDispatcher.TransactionTimeout 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得或設定值,這個值會指定發送器代表服務所建立之新異動的預設逾時。
public:
property TimeSpan TransactionTimeout { TimeSpan get(); void set(TimeSpan value); };
public TimeSpan TransactionTimeout { get; set; }
member this.TransactionTimeout : TimeSpan with get, set
Public Property TransactionTimeout As TimeSpan
屬性值
TimeSpan 值,表示交易的預設逾時期限。 預設為 Zero。
例外狀況
設定的值小於零或太大。
通訊物件處於 Faulted 狀態中。
範例
Uri baseAddress = new Uri("http://localhost:8001/Simple");
ServiceHost serviceHost = new ServiceHost(typeof(CalculatorService), baseAddress);
serviceHost.AddServiceEndpoint(
typeof(ICalculator),
new WSHttpBinding(),
"CalculatorServiceObject");
serviceHost.Open();
IChannelListener icl = serviceHost.ChannelDispatchers[0].Listener;
ChannelDispatcher dispatcher = new ChannelDispatcher(icl);
dispatcher.TransactionTimeout = new TimeSpan(100);
Dim baseAddress As New Uri("http://localhost:8001/Simple")
Dim serviceHost As New ServiceHost(GetType(CalculatorService), baseAddress)
serviceHost.AddServiceEndpoint(GetType(ICalculator), New WSHttpBinding(), "CalculatorServiceObject")
serviceHost.Open()
Dim icl As IChannelListener = serviceHost.ChannelDispatchers(0).Listener
Dim dispatcher As New ChannelDispatcher(icl)
dispatcher.TransactionTimeout = New TimeSpan(100)
備註
只有在 ChannelDispatcher 的執行個體處於 Created 狀態時才可以設定這個屬性,因為這是唯一同時處於可變動且尚未處置的狀態。