新聞中心
這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
WCF托管特性ICommunicationObject接口實現(xiàn)
我們在學習中要不斷的總結(jié)經(jīng)驗,對于一些特性我們應該經(jīng)常做總結(jié),在里就WCF托管特性概要分析一下。在ServiceHost實現(xiàn)的ICommunicationObject接口定義了一些高級特性,如例所示。

WCF托管特性ICommunicationObject接口
- public interface ICommunicationObject
- {
- void Open();
- void Close();
- void Abort();
- event EventHandler Closed;
- event EventHandler Closing;
- event EventHandler Faulted;
- event EventHandler Opened;
- event EventHandler Opening;
- IAsyncResult BeginClose(AsyncCallback callback,object state);
- IAsyncResult BeginOpen(AsyncCallback callback,object state);
- void EndClose(IAsyncResult result);
- void EndOpen(IAsyncResult result);
- CommunicationState State
- {get;}
- //更多成員
- }
- public enum CommunicationState
- {
- Created,
- Opening,
- Opened,
- Closing,
- Closed,
- Faulted
- }
#T#如果打開或關閉宿主的操作耗時較長,可以采用異步方式調(diào)用BeginOpen()和BeginClose()方法。我們可以訂閱諸如狀態(tài)改變或錯誤發(fā)生等宿主事件,通過調(diào)用State屬性查詢當前的宿主狀態(tài)ServiceHost類同樣實現(xiàn)了Abort()方法。該方法提供強行退出功能,能夠及時中斷進程中的所有服務調(diào)用,然后關閉宿主。此時,活動的客戶端會獲得一個異常。以上就是一個關于WCF托管特性的一個列舉,希望大家在以后的學習中累計。
當前文章:WCF托管特性ICommunicationObject接口實現(xiàn)
鏈接分享:http://m.fisionsoft.com.cn/article/dpejhjg.html


咨詢
建站咨詢
