gpt4 book ai didi

c# - 如何手动处理非托管资源?

转载 作者:太空狗 更新时间:2023-10-30 00:21:34 24 4
gpt4 key购买 nike

我正在使用一些非托管代码,例如-

 [DllImport("wininet.dll")]
private extern static bool InternetGetConnectedState(out int Description, int ReservedValue);
//Creating a function that uses the API function...
public static bool IsConnectedToInternet() {
int Desc;
return InternetGetConnectedState(out Desc, 0);
}

关于调用 Dispose 时如何处理/清理这个外部静态对象有什么建议吗?

最佳答案

你认为是“外部静态对象”的东西根本不是对象,它只是一组关于如何在 DLL 中查找函数的编译器/运行时指令。

正如 Sander 所说,没有什么需要清理的。

关于c# - 如何手动处理非托管资源?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4721906/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com