我正在vb.net中的一个dll上工作。我想从dll中调用一个函数,但是当使用该dll的窗体关闭时。
即abc dll以xyz格式使用。 xyz表单已关闭,需要调用函数func。必须在abc dll中定义func。有什么想法吗?
谢谢
答案 0 :(得分:0)
您可以像这样调用onClose方法(这是C#版本):
Form1.FormClosing += new FormClosingEventHandler(Form1_Closing);
....
private void Form1_FormClosing(Object sender, FormClosingEventArgs e)
{
abcDLL.YourMethod();
}
答案 1 :(得分:0)
最好将清理代码放入表单的dispose方法中。打开Form1.Designer.vb
并将代码添加到以下形式的Dispose
方法中:
'Form overrides dispose to clean up the component list.
<System.Diagnostics.DebuggerNonUserCode()> _
Protected Overrides Sub Dispose(ByVal disposing As Boolean)
Try
'
'Your custom cleanup code here
'
If disposing AndAlso components IsNot Nothing Then
components.Dispose()
End If
Finally
MyBase.Dispose(disposing)
End Try
End Sub