ChannelDispatcher.TransactionTimeout 屬性

定義

取得或設定值,這個值會指定發送器代表服務所建立之新異動的預設逾時。Gets or sets a value that specifies the default timeout for new transactions created by the dispatcher on behalf of the service.

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

TimeSpan 值,表示交易的預設逾時期限。A TimeSpan value that represents the default timeout period for transactions. 預設為 ZeroThe default is Zero.

例外狀況

設定的值小於零或太大。The value set is less than zero or is too large.

通訊物件處於 OpeningOpened 狀態中。The communication object is in an Opening or Opened state.

通訊物件處於 ClosingClosed 狀態中。The communication object is in a Closing or Closed state.

通訊物件處於 Faulted 狀態中。The communication object is in a Faulted state.

範例

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 狀態時才可以設定這個屬性,因為這是唯一同時處於可變動且尚未處置的狀態。This property can only be set when the instance of the ChannelDispatcher is in the Created state, as this is the only state that is both mutable and not disposed.

適用於