简体   繁体   English

Eclipse插件IDE已冻结/在处理期间未刷新

[英]Eclipse Plugin IDE frozen / not refreshing during process

I'm developing an Eclipse plugin right now and there's a problem I can't resolve. 我现在正在开发Eclipse插件,有一个我无法解决的问题。 There's this situation: 有这种情况:

I have two processes. 我有两个过程。 Process A fills a View (with a Nebula XViewer table). 进程A填充一个视图(带有Nebula XViewer表)。 Process B uses the data from the view (results in some kind of producer-consumer problem I guess). 流程B使用视图中的数据(我猜这会导致某种生产者-消费者问题)。

Now, I can trigger both processes manually which works perfectly fine. 现在,我可以手动触发这两个过程,效果非常好。 But I also want to have the option to trigger process B automatically when I manually start process A (ofc after A is finished). 但是,我还希望可以选择在手动启动进程A(A完成后的OFC)时自动触发进程B。

The problem is tho, that while the processes are running, the Plugin-Eclipse-IDE is frozen and the view does not get refreshed until the process is finished , even if I call the refresh function of the ViewPart or View. 问题是,在进程运行时,即使我调用ViewPart或View的刷新功能,在进程运行完成时,Plugin-Eclipse-IDE也会冻结, 并且视图不会刷新 This leaves me in the situation that process B starts, but the data in the view is old and not from the last run of process A. 这使我处于进程B启动的情况,但是视图中的数据是旧数据,而不是来自进程A的最后一次运行。

Does someone know how to fix that? 有人知道该如何解决吗? Maybe there is some way to set a commands priority to highest? 也许有某种方法可以将命令优先级设置为最高? To force eclipse to refresh the view before doing something else? 要强制日食在执行其他操作之前刷新视图?

From the sound of your question you have code which takes a long time to run executing in the User Interface thread. 从您的问题的声音来看,您的代码需要花费很长时间才能在用户界面线程中运行。 This is guaranteed to cause the UI to freeze as the UI thread must be kept responsive. 由于必须保持UI线程响应,因此可以保证UI冻结。 Long running code should be run in the background using an Eclipse Job or a Thread. 长时间运行的代码应使用Eclipse Job或Thread在后台运行。

When you are running code in the background you cannot update the UI directly. 在后台运行代码时,无法直接更新UI。 Instead you will have to use the asyncExec or syncExec methods of Display to update the UI. 相反,您将必须使用DisplayasyncExecsyncExec方法来更新UI。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM