Invoke runnable after another task finishes Follow
My plugin does some long calculations in order to later display calculated data in Editor. Therefore, when my FileOpenListener is invoked I need to somehow check are my calculations finished, and, if not, wait for them to finish and only after this display calculated data.
So, I need something like "invoke if another task completed or wait until it completes". How can I do this?
Please sign in to leave a comment.
I assume you mean com.intellij.openapi.fileEditor.FileEditorManagerListener#fileOpened.
Do you start calculating from there? What kind of data is displayed later and how is it applied to the editor?
No, calculation starts in my implementation of com.intellij.openapi.components.ProjectComponent on project opening.
Data is added to Editor's InlayModel via block elements.
The easiest way in my opinion is to just check if data processing is finished in a while loop, but this seems not good. Therefore I want to know, if there is something out of the box in intellij-openapi, or should I use standart Java ExecutorService for this.
Does org.jetbrains.concurrency.Promises help?
I've solved this with
and passing Future returned by this method in FileOpenedHandler's constructor. So it works OK for now.