I have to call multiple WCF methods in sequence without blocking the UI thread.
Each method have to be completed before the next method is called.
I have setup my WCF service with svcutil so I have an async version of my synchronous methods available.
If I call the async version, the methods will execute simultaneously, what I want to avoid.
If I call the sync version, the UI thread is blocked so my UI is unresponsive, what I want to avoid.
How can I call the async version and wait for each call to complete before the next call, without blocking the UI thread ?
Say I have to loop for each occurence of objects to be treated by a WCF method :
foreach (MyObject obj in SomeCollection)
{
myWCFProxy.TreatObject(obj); // This is a duplex service and I am handling its callback in a separate method.
// I would like to wait here (without blocking the UI thread) until the method returns.
}
How can I do this ?
Based on your description, the simplest solution might be to use a BackgroundWorker to execute the WCF calls synchronously.