ChannelDispatcher.Detach(ServiceHostBase) 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
從通道發送器中斷服務主機的連結。
protected:
override void Detach(System::ServiceModel::ServiceHostBase ^ host);
protected override void Detach (System.ServiceModel.ServiceHostBase host);
override this.Detach : System.ServiceModel.ServiceHostBase -> unit
Protected Overrides Sub Detach (host As ServiceHostBase)
參數
- host
- ServiceHostBase
服務的 ServiceHostBase。
例外狀況
host
為 null
。
通訊物件處於 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.CloseInput();
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.CloseInput()
備註
ServiceHostBase 只有在 ChannelDispatcher 的執行個體處於 Created 狀態時才可以進行中斷,因為這是唯一同時處於可變動且尚未處置的狀態。
將與通道發送器關聯的 ServiceHostBase 設定為 null
。