swt子外壳,按钮选择有一个for循环,需要执行5秒钟以上的时间 SWT GUI冻结5秒后无响应

问题描述

因此,单击按钮后,UI在5秒钟后没有响应,并且一旦迭代结束,它就会响应。我希望这种反应不会发生。请您提供任何建议吗?

我试图使用syncExec和asyncExec在后台线程中执行代码,但是没有运气..

解决方法

syncExec和asyncExec不运行后台线程。它们在UI线程中运行select top 1 a.*,b.ViewPriority from CustomerAgreementRole a left join AgreementRoleGroup b on a.AgreementRoleId=b.AgreementRoleId order by ViewPriority asc ,用于从您创建的后台线程中运行的代码访问SWT控件。

您可以启动后台线程,然后在每次要更新控件时调用Runnable

因此在后台线程中,您将如下所示:

asyncExec

如果此代码位于Eclipse插件中,则可以使用for (.....) { ... your calculation Display.getDefault().asyncExec(code to update a control); } 作为后台线程。

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...