RELATEED CONSULTING
相关咨询
选择下列产品马上在线沟通
服务时间:8:30-17:00
你可能遇到了下面的问题
关闭右侧工具栏

新闻中心

这里有您想知道的互联网营销解决方案
WCF托管特性ICommunicationObject接口实现

我们在学习中要不断的总结经验,对于一些特性我们应该经常做总结,在里就WCF托管特性概要分析一下。在ServiceHost实现的ICommunicationObject接口定义了一些高级特性,如例所示。

WCF托管特性ICommunicationObject接口

 
 
  1. public interface ICommunicationObject  
  2. {  
  3. void Open();  
  4. void Close();  
  5. void Abort();  
  6. event EventHandler Closed;  
  7. event EventHandler Closing;  
  8. event EventHandler Faulted;  
  9. event EventHandler Opened;  
  10. event EventHandler Opening;  
  11. IAsyncResult BeginClose(AsyncCallback callback,object state);  
  12. IAsyncResult BeginOpen(AsyncCallback callback,object state);  
  13. void EndClose(IAsyncResult result);  
  14. void EndOpen(IAsyncResult result);  
  15. CommunicationState State  
  16. {get;}  
  17. //更多成员  
  18. }  
  19. public enum CommunicationState  
  20. {  
  21. Created,  
  22. Opening,  
  23. Opened,  
  24. Closing,  
  25. Closed,  
  26. Faulted  

#T#如果打开或关闭宿主的操作耗时较长,可以采用异步方式调用BeginOpen()和BeginClose()方法。我们可以订阅诸如状态改变或错误发生等宿主事件,通过调用State属性查询当前的宿主状态ServiceHost类同样实现了Abort()方法。该方法提供强行退出功能,能够及时中断进程中的所有服务调用,然后关闭宿主。此时,活动的客户端会获得一个异常。以上就是一个关于WCF托管特性的一个列举,希望大家在以后的学习中累计。


分享题目:WCF托管特性ICommunicationObject接口实现
文章位置:http://www.jxjierui.cn/article/dpejhjg.html