I only want to receive my message in a async method! and its freezing my UI
public async void ProcessMessages()
{
MessageQueue MyMessageQueue = n
async does not run your code on a background thread. Your code above should have caused a compiler warning that tells you that your method will run synchronously.
If you want to execute a method on a background thread, use TaskEx.Run
:
public void ProcessMessages()
{
...
}
TaskEx.Run(() => ProcessMessages());