检测是否处置了控制 [英] Detect if control was disposed
本文介绍了检测是否处置了控制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我的应用程序中,我有一个使用线程池执行异步操作的用户控件.线程池方法看起来像:
In my application I have a user control that do async operations using thread pool. The thread pool method looks like:
private void AsyncFunction(object state)
{
... do the calculation
//refresh the grid data on the UI thread
this.BeginInvoke(new MethodInvoker(() =>
{
... update the ui
}));
}
我的问题是,如果用户关闭对话框...则用户控件被处置,并且出现异常:
My problem is that if the user closes the dialog ... the user control gets disposed and I get the exception:
Invoke或BeginInvoke.
您知道一种检测对话框是否被处置的方法吗?我不想在对话框关闭时设置控件的属性.有解决这个问题的另一种方法吗?
Do you know a way to detect if the dialog was disposed? I don't want to hae a property on control that the dialog set when closed. Is there another way of solving this?
谢谢
Radu
推荐答案
这篇关于检测是否处置了控制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文