Computationally expensive action

Answered

I have a computationally expensive action that can happen on certain user events. The event does not need to finish before the user continues, so I would like to push the event onto a separate thread. Then there should be no hanging from the user's perspective. Is there a official way to do this in the API or should I just use standard Java threading?

2 comments
Comment actions Permalink

You can use standard Java threading, but it's preferrable to use Application thread pool.

See `com.intellij.openapi.application.ApplicationManager.getApplication().executeOnPooledThread(Runnable)`, `com.intellij.util.Alarm`, `com.intellij.util.concurrency.AppExecutorUtil.createBoundedApplicationPoolExecutor`.

See also com.intellij.openapi.progress.Task.Modal/Task.Backgroundable, which can be used to start user-visible background task.

1

Please sign in to leave a comment.