How to switch from runProcessWithProgressSynchronously to runProcessWithProgressAsynchronously?

One of my plugins which updates project is using runProcessWithProgressSynchronously(). Problem with this is: progress indicator is a modal dialog, blocking user from doing any operation on other intellij windows. Is there a way to invoke this progress indicator as non-modal dialog?

3 comments
Comment actions Permalink

Hello,

ProgressManager.getInstance().run(new Task.Backgroundable(...) {
    public void run() {
        ...
    }
});

Denis

0
Comment actions Permalink

I tried that, but getting following exception: [a bit background on the plugin: this plugin updates intellij project files like: .iml and we are displaying progress using modal dialog box and this modal blocks all other windows of IntelliJ].

Here is the exception: Any idea on how to fix this?

Read access is allowed from event dispatch thread or inside read-action only (see com.intellij.openapi.application.Application.runReadAction())
Details: Current thread: Thread[ApplicationImpl pooled thread 13,4,Idea Thread Group] 2061637008
Our dispatch thread:Thread[AWT-EventQueue-1 10.5.2#IU-107.587, eap:false,6,Idea Thread Group] 472236880
SystemEventQueueThread: Thread[AWT-EventQueue-1 10.5.2#IU-107.587, eap:false,6,Idea Thread Group] 472236880
java.lang.Throwable
 at com.intellij.openapi.diagnostic.Logger.error(Logger.java:59)
 at com.intellij.openapi.application.impl.ApplicationImpl.assertReadAccessAllowed(ApplicationImpl.java:901)
 at com.intellij.openapi.roots.impl.ModuleRootManagerImpl.getModifiableModel(ModuleRootManagerImpl.java:145)
 at com.intellij.openapi.roots.impl.ModuleRootManagerImpl.getModifiableModel(ModuleRootManagerImpl.java:140)
 at com.google.myplugin.InProcessProjectUpdater.replaceSourceRootsAndLibraries(InProcessProjectUpdater.java:255)
 at com.google.myplugin.ProjectUpdater.update(ProjectUpdater.java:94)
 at com.google.myplugin.ProjectBuilder.updateSettings(ProjectBuilder.java:120)
 at com.google.myplugin.NewProjectCreator$2.call(NewProjectCreator.java:325)
 at com.google.myplugin.NewProjectCreator$2.call(NewProjectCreator.java:294)
 at com.google.myplugin.UiUtil$1.run(UiUtil.java:79)
 at com.intellij.openapi.progress.impl.ProgressManagerImpl$TaskRunnable.run(ProgressManagerImpl.java:423)
 at com.intellij.openapi.progress.impl.ProgressManagerImpl$2.run(ProgressManagerImpl.java:174)
 at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:202)
 at com.intellij.openapi.progress.impl.ProgressManagerImpl.runProcess(ProgressManagerImpl.java:165)
 at com.intellij.openapi.progress.impl.ProgressManagerImpl$6.run(ProgressManagerImpl.java:332)
 at com.intellij.openapi.application.impl.ApplicationImpl$7.run(ApplicationImpl.java:386)
 at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
 at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
 at java.util.concurrent.FutureTask.run(FutureTask.java:166)
 at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
 at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
 at java.lang.Thread.run(Thread.java:679)
 at com.intellij.openapi.application.impl.ApplicationImpl$1$1.run(ApplicationImpl.java:130)

0
Comment actions Permalink

Exception message contains the answer. You didn't have the exception before because Event Dispatch Thread has read access implicitly. See more at http://confluence.jetbrains.net/display/IDEADEV/IntelliJ+IDEA+Architectural+Overview

0

Please sign in to leave a comment.