I have a JList in my toolwindow and when I click on each row, a background process is run and on completion another part of my toolwindow is populated with the content. I am using ProgressManager.getInstance().run() to achieve the background process. This works perfectly. Now, when I click on a row and then click on another row and so on (like for 6 times), for each click a backgroud process is run (6 process). This is not what I want.
Once the user clicks on one row and immediately clicks on 2nd row, I want to cancel the first process and move on the 2nd one. So if there are 6 clicks done, I am only concered about the result of the 6th process. Hence I wish to remove all the other process from the queue.
1) Can this be done in the IntelliJ API, or should I manually take care of the queuing part.
2) Is there any way to get a list of all the background processes and kill the ones I don't want ?
3) Does ProgressManager.getInstance().run() queues the tasks, or does it run eveything in parallel? If not, what API does the background processes in a queue ?