IClosable Interface

Definition

Defines a method to release allocated resources.

.NET This interface appears as System.IDisposable.

C++/CX This interface appears as Platform::IDisposable.

public interface class IClosable
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.FoundationContract, 65536)]
/// [Windows.Foundation.Metadata.Guid(819308585, 32676, 16422, 131, 187, 215, 91, 174, 78, 169, 158)]
struct IClosable
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.FoundationContract), 65536)]
[Windows.Foundation.Metadata.Guid(819308585, 32676, 16422, 131, 187, 215, 91, 174, 78, 169, 158)]
public interface IDisposable
Public Interface IDisposable
Attributes

Windows requirements

Device family
Windows 10 (introduced in 10.0.10240.0)
API contract
Windows.Foundation.FoundationContract (introduced in v1.0)

Remarks

This interface is projected to a different interface for all possible languages, so it should be considered as an infrastructure piece that the overall Windows Runtime programming experience uses as an implementation detail. There are no typical app development scenarios that rely on implementing or using the IClosable interface directly, unless you're using WRL. For more info, see WRL Integration.

Notes to implementers

When programming with .NET, this interface is hidden and is replaced by the System.IDisposable interface.

If you are defining a runtime class in C++/CX and define a destructor, don't implement IClosable. There's already compiler-based behavior that implements a cleanup behavior for you, (as Platform::IDisposable) and your explicit implementation will clash with the built-in behavior. For more info, see the "Destructors" section of Ref classes and structs (C++/CX).

The purpose of this interface (as exposed by the languages) is so that Windows Runtime objects can wrap and dispose of exclusive system or device/hardware resources appropriately, such as file handles and network sockets. You do not implement this interface for Windows Runtime objects that wrap shared system resources, such as memory and shareable devices.

Notes to callers

The scenario for Platform::IDisposable/System.IDisposable is to support language-specific syntax that isolates references, such as the using() syntax in C#, or scoping behavior for reference counting in C++. Actually casting to the interfaces or invoking its methods from any app code in any language is rarely necessary.

Methods

Close()

Releases system resources that are exposed by a Windows Runtime object.

.NET This interface appears as System.IDisposable.

C++/CX This interface appears as Platform::IDisposable.

Applies to

See also