IClosable 介面

定義

定義釋放已配置資源的方法。

。網 此介面會顯示為 System.IDisposable

C++/CX 此介面會顯示為 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
屬性

Windows 需求

裝置系列
Windows 10 (已於 10.0.10240.0 引進)
API contract
Windows.Foundation.FoundationContract (已於 v1.0 引進)

備註

此介面會針對所有可能的語言投影到不同的介面,因此應該將其視為整體Windows 執行階段程式設計體驗作為實作詳細資料的基礎結構部分。 除非您使用 WRL,否則沒有一般應用程式開發案例依賴實作或使用 IClosable 介面。 如需詳細資訊,請參閱 WRL 整合

實作者的注意事項

使用 .NET 進行程式設計時,此介面會隱藏,並由 System.IDisposable 介面取代。

如果您要在 C++/CX 中定義執行時間類別並定義解構函式,請勿實作 IClosable。 已經有編譯器型行為會為您實作清除行為, (為 Platform::IDisposable) ,而您的明確實作將會與內建行為衝突。 如需詳細資訊,請參閱 Ref 類別和結構 (C++/CX) 的一節。

此介面的用途 (由語言公開) ,讓Windows 執行階段物件可以適當地包裝和處置專屬的系統或裝置/硬體資源,例如檔案控制代碼和網路通訊端。 您不會針對包裝共用系統資源的Windows 執行階段物件實作此介面,例如記憶體和可共用裝置。

來電者的附注

Platform::IDisposableSystem.IDisposable/ 的案例是支援特定語言語法來隔離參考,例如C# 中的 using () 語法,或 C++ 中參考計數的範圍行為。 實際上,幾乎不需要從任何語言的任何應用程式程式碼轉換至介面或叫用其方法。

方法

Close()

釋放由 Windows 執行階段 物件公開的系統資源。

。網 此介面會顯示為 System.IDisposable

C++/CX 此介面會顯示為 Platform::IDisposable

適用於

另請參閱