Run WriteAction in Background process Asynchronously

Answered

Hello. 

I am trying to run this code:

ProgressManager.getInstance().runProcessWithProgressAsynchronously(new RunnableBackgroundableWrapper(project,"BackGround process", new BackgroundRunnable()), new ProgressIndicatorBase() );

But BackgroundRunnable execute this code:

ApplicationManager.getApplication().runWriteAction(new Runnable(){...})

and i get RuntimeException.

I guess tan writeActions are not allowed under asynchronous background processes. So is there way to run my BackgroundRunnable asynchronously?

6 comments
Comment actions Permalink

I want to add library to the module. According to your guide it possible to do only under writeAction

0
Comment actions Permalink

Why should this be done asynchronously and/or with progress bar?

 

0
Comment actions Permalink

Because BackgroundRunnable download 40 MB library at first and only after that adds library to the module. So 40MB downloading can take some time

0
Comment actions Permalink

You can use Task.Backgroundable directly (without all the wrappers) and then override com.intellij.openapi.progress.Task#onSuccess to invoke Write Action

1
Comment actions Permalink

Oh, thank you! I will try

0

Please sign in to leave a comment.