Problems with a long running action w/ progress

I'm having some trouble with a long running action (in my case, it is a project resynchronisation of VCS)

Currently, I'm starting it with runReadAction() in a helper thread and displaying a (custom) progress dialog. As the UI Thread is not blocked that way, one can nicely watch the progress. However, if one switches to another Task and back, the UI Thread gets blocked with a write-action which is waiting on my long-lasting-read-action to finish (I suspect the culprit in the file-resync-on-frame-activation). Even worse, on certain circumstances another dialog has to be displayed during the progress. This leads to a deadlock, as the UI Thread is waiting on the secondary thread to finish and vice-versa.

Is there any way to prevent IDEA from executing new actions on the UI Thread while my Action is running? Any idea for another way to solve this problem?


I'm still in need of a solution to this problem. Mike, how does IDEA handle this (e.g. on compilation)?


ok, as nobody seems to know how to do it, I tried a bit more, and at least it now works without deadlocking when swiching applications:

1) run your task in a separate thread NOT using runRead/WriteAction around the whole task
2) for every single call that needs a lock lock it just for a very short time

the only problem is that one can still "use" IDEA while the task is running. Maybe I can work around this with a glass-pane on the IDEA frame, but I did not try it yet.