Asynchronous Web Service Calls are swell
Asynchronous Web Service calls are a beautiful thing. Web services I was executing from a console app I mentioned earlier were timing out and Asynchronous WS calls got me back in the pink. I sketched out the basic framework in using an asynchronous call below. I won't provide a play-by-play because there are good references elsewhere.
private static void CoolWebService()
{
Appname.Component oComponent = new Appname.Component();
Appname.Server.Class ws = new Appname.Server.Class();
AsyncCallback cb = new AsyncCallback(THISClass.CoolWebServiceCallback);
IAsyncResult ar = ws.BeginCoolWebService(cb, ws);
while (ar.IsCompleted == false)
{
// wait
}
}
public static void CoolWebServiceCallback(IAsyncResult ar)
{
Appname.Server.Class ws = (Appname.Server.Class) ar.AsyncState;
ws.EndCoolWebService(ar);
}