在IDisposable.Dispose()
方法内部,我启动了频道的ICommunicationObject.Close()
方法。如果频道的ICommunicationObject.Close()
位于CommunicationState
,是否可以拨打CommunicationState.Opening
?
即。这样的检查是否足以使ICommunicationObject
实例关闭?
ICommunicationObject commObj = channel as ICommunicationObject;
if (null != commObj &&
commObj.State == CommunicationState.Opened ||
commObj.State == CommunicationState.Opening) {
commObj.Close();
}
答案 0 :(得分:0)
我相信您只需查看commObj.State != CommunicationState.Closed
。
我多年来一直在运行A smarter WCF service client的变体而没有问题。