本文介绍了两次调用导致:“ protected Override void Dispose”;的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个函数可以帮助我关闭表单而不会出现跨线程错误:
I have a function that helps me close forms without getting crossthread errors:
public void OutsideClose(long Id)
{
MessageBox.Show("");
if (InvokeRequired)
{
Invoke(new Action<long>(OutsideClose), Id);
}
else
{
var asdf = ListForm.Find(a => a.Id == Id);
if (asdf != null)
{
asdf.Close();
}
}
}
出于某些原因,如果我两次调用此调用,而不是第二次关闭该表单,而是转到此dispose方法:
For some reason, if I call this invoke twice, instead of closing the form the second time, it goes to this dispose method:
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
我要关闭表单,不知道发生了什么。 ..
I want the form to close, and have no idea what is going on...
推荐答案
asdf.Close应该调用asdf.Dispose。
asdf.Close should calls asdf.Dispose.
这篇关于两次调用导致:“ protected Override void Dispose”;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!