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?

0
6 comments

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

0

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

 

0

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

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

1

Oh, thank you! I will try

0

Please sign in to leave a comment.