Dave Burke : Freelance .NET Web Developer specializing in Online Communities

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);
}

Comments (0) | Post RSS RSS comment feed

Posted on 8/29/2003 9:34:00 PM by Dave Burke
Categories:
Tags:

Related posts


Powered by BlogEngine.NET 2.0.0.36
Theme by Dave Burke