/// <summary> /// Callback raised when response is received /// </summary> /// <param name="result">indicating the async result</param> private void ReceiveResponse(IAsyncResult result) { object[] objArr = result.AsyncState as object[]; UniqueId messageId = objArr[0] as UniqueId; IDuplexCallbackService callback = objArr[1] as IDuplexCallbackService; Message response; try { lock (this.client) { response = this.client.EndProcessMessage(result); } } catch (Exception e) { // Communication/Timeout/EndpointNotFound exception could throw here // Build fault message instead and send back to client Trace.TraceError("[ServiceClientManager] Failed to process the message: {0}", e); response = this.BuildFaultMessage(messageId, e); } try { // Send back response to client side callback.SendResponse(response); } catch (Exception e) { // Failed to send response // Swallow the exception and log it Trace.TraceError("[ServiceClientManager] Failed to send back response: {0}", e); } }