예제 #1
0
                public WriteMessageAsyncResult(Message message, Stream stream, TextMessageEncoder textEncoder, AsyncCallback callback, object state)
                    : base(callback, state)
                {
                    this.message = message;                    
                    this.textEncoder = textEncoder;
                    this.xmlWriter = textEncoder.TakeStreamedWriter(stream);


                    this.eventTraceActivity = null;
                    if (TD.TextMessageEncodingStartIsEnabled())
                    {
                        this.eventTraceActivity = EventTraceActivityHelper.TryExtractActivity(message);
                        TD.TextMessageEncodingStart(this.eventTraceActivity);
                    }

                    if (!textEncoder.optimizeWriteForUTF8)
                    {
                        xmlWriter.WriteStartDocument();
                    }

                    IAsyncResult result = message.BeginWriteMessage(this.xmlWriter, PrepareAsyncCompletion(onWriteMessage), this);                    
                    if (SyncContinue(result))
                    {
                        this.Complete(true);
                    }
                }