Quote Originally Posted by gstercken
Well, the code shows what you're currently doing, not what you want to happen. It's pretty obvious that calling Sleep() in your main thread freezes the UI.

As said above: What would you like to happen? It's still unclear how you expect your app to behave.
Thank you for your reply.
While the handler waits for the thread to end I want to be able to press other buttons in my dialog. This is not possible now. My main thread freezes the UI.