I solved it by queing all "Refresh" and all the other GUI calls to the main thread (which is quite uncomfortable).
Thank you for explanation, but do i understand correctly (also looking at the code), that the main thread is unlocking lock which it doesn't own? This looks really bad to me. The classic method to avoid deadlocks is to acquire them in some fixed order, but it fails then.
Basically, can this happen? (GM-GMutex,OM-other mutex,T-thread,MT-main thread)
T: GM->OM->GM unlocked, preempted
MT:waiting on GM->GM->waiting on OM
T: ->waiting on GM