Dispose Method (Boolean)
Collapse the table of content
Expand the table of content

Stream.Dispose Method (Boolean)

[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]

Releases the unmanaged resources used by the Stream and optionally releases the managed resources.

Namespace:  System.IO
Assembly:  mscorlib (in mscorlib.dll)

protected virtual void Dispose(
	bool disposing
)

Parameters

disposing
Type: System.Boolean
true to release both managed and unmanaged resources; false to release only unmanaged resources.

You should release all resources by specifying true for disposing. When disposing is true, the stream can also ensure data is flushed to the underlying buffer, and access other finalizable objects. This may not be possible when called from a finalizer due a lack of ordering among finalizers.

This method is called by the Finalize method. Finalize invokes Dispose with disposing set to false.

Notes to Inheritors

In derived classes, do not override the Close method, instead, put all of the Stream cleanup logic in the Dispose method.

Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Windows Phone

Show:
© 2017 Microsoft