在IntelliJ插件中创建后台任务

问题描述 投票:10回答:2

我正在开发IntelliJ-idea插件,并希望在后台任务中运行代码(在后台任务对话框和UI之外的其他线程中可见)。>>

我发现以下Helper class,并通过传递一个Runnable对象并实现其run方法进行了尝试,但它仍然阻塞了UI,当我尝试自己进行线程处理时出现以下错误

 Read access is allowed from event dispatch thread or inside read-action only (see com.intellij.openapi.application.Application.runReadAction())
     Details: Current thread: Thread[Thread-69 [WriteAccessToken],6,Idea Thread Group] 532224832
     Our dispatch thread:Thread[AWT-EventQueue-1 12.1.4#IU-129.713, eap:false,6,Idea Thread Group] 324031064
     SystemEventQueueThread: Thread[AWT-EventQueue-1 12.1.4#IU-129.713, eap:false,6,Idea Thread Group] 324031064

我正在开发IntelliJ-idea插件,并希望在后台任务中运行代码(在后台任务对话框和UI之外的其他线程中可见)。我找到了以下Helper类,并尝试了...

java intellij-idea intellij-plugin
2个回答
8
投票

这是一般解决方案


7
投票

我发现了一种更好的方式将流程作为后台任务运行,您可以在其中更新进度条的百分比和文本

© www.soinside.com 2019 - 2024. All rights reserved.