Quote Originally Posted by zvivered
I have a dialog that does a certain operation in a thread. I create the thread upon pressing a button.
From the button handler I want to wait till the thread ends.
If I wait till the thread turns on a flag, the GUI is freeze.
What is the optimal way to do it ?
Not sure what you really want. Without a worker thread, your GUI would wait for the operation to complete (and hence freeze). You normally introduce a worker thread so that your GUI does not have to wait. Now you say you want to wait - so why the thread? What do you mean by "waiting" without freezing? What exactly is the behaviour you are expecting?