我正在翻译一个将非托管库包装到F#的C#类.我遇到了重写后面的析构函数这个看似简单的问题.
class Wrapper {
// P/Invoke ellided
private SomeType x;
public Wrapper() {
x = new SomeType();
Begin();
}
public ~Wrapper() {
End();
}
Run Code Online (Sandbox Code Playgroud)
我现在简化的F#代码如下:
type Wrapper() =
[<Literal>]
static let wrappedDll = "Library.dll"
[<DllImport(wrappedDll , EntryPoint = "Begin")>]
static extern void Begin()
[<DllImport(wrappedDll , EntryPoint = "End")>]
static extern void End()
let x = new SomeType()
do
Begin()
Run Code Online (Sandbox Code Playgroud)
如何修改此F#代码以具有相同的行为?我对F#析构函数的搜索没有出现在我的书籍或网络上.
谢谢.