Search code examples
.netwindowsuser-interfaceasynchronousmessage-pump

Sending a message to the Windows GUI Thread


I've noticed that when you create a web service object (inheriting from SoapHttpClientProtocol) and you use the Async method, it makes the callback on the Windows GUI thread.

  1. Does anyone know how this works?
  2. How can I achieve the same thing.

I figure this will save me having to check for InvokeRequired in my GUI forms if I am sure the callback is always occurring on the gui thread.


Solution

  • I suspect it uses AsyncOperationmanager.SynchronizationContext to statically get a synchronization context. This then allows you to post callbacks appropriately.