How to create a background invisible process?
已回答
Hi!
I need to consume an external API asynchronously (Google Analytics by the way). I was looking documentation about that and found this
And it said:
Background progresses are managed by ProgressManager class, which has plenty of methods to execute the given code with a modal (dialog), non-modal (visible in the status bar), or invisible progress.
So I was do the following:
ProgressManager.getInstance().run(new Task.Backgroundable(null, "Consume API", false) {
@Override
public void run(@NotNull ProgressIndicator indicator) {
// Consuming API stuff
}
});
It's that correct? The documentation talks abouts method for invisible process, but I can't find them.
Thanks in advance =)
请先登录再写评论。
Cristóbal, documentation states about an invisible progress, not process.
Your snippet is correct, but you have to be aware that Consume API task will still show up in the current running tasks on the bottom of IDE.
Thanks Jakub. You're absolutely right! I didn't realize it said "progress" and not "process". Do you have any recommendations for running an asynchronous task in the background?
invokeLater should be fine.
I did that, but I have a synchronous behaviour.
So when I run the plugin I have:
What I'm doing wrong?
Thanks in advance.
Sorry for the late reply, in that case, you should try with executeOnPooledThread().
That was exactly the method I used.
Thanks anyway.