System.IO.BufferedStream.Dispose C# (CSharp) Méthode

Dispose() protected méthode

protected Dispose ( bool disposing ) : void
disposing bool
Résultat void
        protected override void Dispose(bool disposing)
        {
            try
            {
                if (disposing && _stream != null)
                {
                    try
                    {
                        Flush();
                    }
                    finally
                    {
                        _stream.Dispose();
                    }
                }
            }
            finally
            {
                _stream = null;
                _buffer = null;

                // Call base.Dispose(bool) to cleanup async IO resources
                base.Dispose(disposing);
            }
        }

Usage Example

Exemple #1
0
		public static void SerializeUtf8 (XmlSerializer serializer, Stream stream, object o)
		{
			if (serializer == null)
				throw new ArgumentNullException ("serializer");

			if (stream == null)
				throw new ArgumentNullException ("stream");

			if (o == null)
				throw new ArgumentNullException ("o");

			UnclosableStream unclosable_stream = new UnclosableStream (stream);
			BufferedStream buffered_stream = new BufferedStream (unclosable_stream, 8192);

			Stopwatch w = new Stopwatch ();
			w.Start ();
			XmlTextWriter xml_writer = new XmlTextWriter (buffered_stream, Encoding.UTF8);
			xml_writer.Formatting = Formatting.Indented;
			serializer.Serialize (xml_writer, o);

			// This will flush the stream and release the buffer.
			// Normally it also closes the underlying stream,
			// which is why it wraps an UnclosableStream.
			buffered_stream.Dispose ();
			w.Stop ();

			if (Debug)
				Log.Debug (">>> Serialization of {0}: {1}", o.GetType (), w);
		}
All Usage Examples Of System.IO.BufferedStream::Dispose