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?
Please sign in to leave a comment.
What exactly do you want to do in your runnable? Please also see http://www.jetbrains.org/intellij/sdk/docs/basics/architectural_overview/general_threading_rules.html
I want to add library to the module. According to your guide it possible to do only under writeAction
Why should this be done asynchronously and/or with progress bar?
Because BackgroundRunnable download 40 MB library at first and only after that adds library to the module. So 40MB downloading can take some time
You can use Task.Backgroundable directly (without all the wrappers) and then override com.intellij.openapi.progress.Task#onSuccess to invoke Write Action
Oh, thank you! I will try