bool HandleWriteMessage(IAsyncResult result) { message.EndWriteMessage(result); if (!textEncoder.optimizeWriteForUTF8) { this.xmlWriter.WriteEndDocument(); } xmlWriter.Flush(); // blocking call textEncoder.ReturnStreamedWriter(this.xmlWriter); if (TD.MessageWrittenAsynchronouslyByEncoderIsEnabled()) { TD.MessageWrittenAsynchronouslyByEncoder( this.eventTraceActivity ?? EventTraceActivityHelper.TryExtractActivity(message)); } if (MessageLogger.LogMessagesAtTransportLevel) { MessageLogger.LogMessage(ref message, MessageLoggingSource.TransportSend); } return(true); }