gpt4 book ai didi

c# - 检测控件是否被处置

转载 作者:可可西里 更新时间:2023-11-01 07:52:25 26 4
gpt4 key购买 nike

在我的应用程序中,我有一个使用线程池执行异步操作的用户控件。线程池方法如下所示:

private void AsyncFunction(object state)
{
... do the calculation
//refresh the grid data on the UI thread
this.BeginInvoke(new MethodInvoker(() =>
{
... update the ui
}));
}

我的问题是,如果用户关闭对话框......用户控件被处理,我得到异常:

在创建窗口句柄之前,无法对控件调用 Invoke 或 BeginInvoke。

您知道检测对话框是否被释放的方法吗?我不想在对话框关闭时设置控件的属性。还有其他方法可以解决这个问题吗?

谢谢,

拉杜

最佳答案

关于c# - 检测控件是否被处置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4460709/

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