WaitOne()
is a blocking call.
The UI thread will not receive any messages until WaitOne()
returns. Since you set the wait handle when the UI thread receives a message, you have a deadlock.
You need to do this on a background thread, or simply call a callback when you receive the message.