System.IO.StreamWriter.Flush C# (CSharp) Method

Flush() public method

public Flush ( ) : void
return void
        public override void Flush()
        {
            CheckAsyncTaskInProgress();

            Flush(true, true);
        }

Same methods

StreamWriter::Flush ( bool flushStream, bool flushEncoder ) : void

Usage Example

        //OnWriteToStreamAsync(Type type, object value, Stream stream, HttpContentHeaders contentHeaders, FormatterContext formatterContext, TransportContext transportContext)
        public override Task WriteToStreamAsync(Type type, object value, Stream writeStream, HttpContent content, TransportContext transportContext)
        {
            string uri = HttpContext.Current.Request.Url.Query;
            string method = HttpContext.Current.Request.HttpMethod;
            if(HttpContext.Current.Request.HttpMethod =="GET")
            {

                return Task.Factory.StartNew(() =>
                {
                    var writer = new StreamWriter(writeStream);
                    var query = HttpUtility.ParseQueryString(uri);
                    string callback = query[CallbackQueryParameter];
                    writer.Write(callback + "(");
                    writer.Flush();

                    base.WriteToStreamAsync(type, value, writeStream, content, transportContext).Wait();

                    writer.Write(")");
                    writer.Flush();
                });
            }
            else
            {
                return base.WriteToStreamAsync(type, value, writeStream, content, transportContext);
            }
        }
All Usage Examples Of System.IO.StreamWriter::Flush