2016-05-04 13 views
0

Innerhalb von IDisposable.Dispose() Methode starte ich ICommunicationObject.Close() Methode meines Kanals. Ist es erlaubt, ICommunicationObject.Close() anzurufen, wenn die CommunicationState des Kanals in CommunicationState.Opening ist?Ist es erlaubt, `ICommunicationObject.Close()` aufzurufen, wenn der 'CommunicationState' des Kanals in 'CommunicationState.Opening' ist?

I.e. Ist eine solche Überprüfung ausreichend für das Schließen der Instanz ICommunicationObject?

ICommunicationObject commObj = channel as ICommunicationObject; 
if (null != commObj && 
    commObj.State == CommunicationState.Opened || 
    commObj.State == CommunicationState.Opening) { 

    commObj.Close(); 
} 

Antwort