IDisposable Interface
Collapse the table of content
Expand the table of content

IDisposable Interface

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

Defines a method to release allocated resources.

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

public interface IDisposable

The IDisposable type exposes the following members.

Public methodDisposePerforms application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

The primary use of this interface is to release unmanaged resources. The garbage collector automatically releases the memory allocated to a managed object when that object is no longer used. However, it is not possible to predict when garbage collection will occur. Furthermore, the garbage collector has no knowledge of unmanaged resources such as window handles, or open files and streams.

Most Windows Phone apps consume unmanaged resources only when you access isolated storage with the IsolatedStorageFile class. A good practice is to use the using statement (Using in Visual Basic) with classes that use unmanaged resources, because the using statement calls Dispose for you after your code is finished with the object. For an example of the using statement being used with the IsolatedStorageFile class, see Data for Windows Phone 8.

Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Windows Phone

© 2017 Microsoft