I have a WPF app that uploads XML data to a web service asynchronously. I call the web service from a non-UI thread:
Task.Factory.StartNew(() => {
WebServiceHelper.ImportMarketDataAsync(....);
});
I have generated the proxy using wsdl.exe. The proxy class provides two different ways to call the web service function asynchronously:
1) *MethodName*Async
2) Begin*MethodName* & End*MethodName*
The first method uses SoapHttpClientProtocol.InvokeAsync and the second method uses SoapHttpClientProtocol.BeginInvoke.
In either case, when the proxy hits the invoke function (i.e. InvokeAsync or BeginInvoke), the web service call is invoked from within the UI thread and therefore the application appears unresponsive since the UI thread is busy. If I call the async function in a foreach loop for a collection of say 250 elements, the UI will freeze until all async calls are complete.
Is there a way to call the asmx web service without blocking the main UI thread?
Thanks in advanced!