How to call WCF Service Method Asycroniously from Class file?
Posted
by stackuser1
on Stack Overflow
See other posts from Stack Overflow
or by stackuser1
Published on 2010-06-01T09:51:55Z
Indexed on
2010/06/01
9:53 UTC
Read the original article
Hit count: 448
I've added WCF Service reference to my asp.net application and configured that reference to support asncronious calls. From asp.net code behind files, i'm able to call the service methods asyncroniously like the bellow sample code.
protected void Button1_Click(object sender, EventArgs e) {
PageAsyncTask pat = new PageAsyncTask(BeiginGetDataAsync, EndDataRetrieveAsync, null, null);
Page.RegisterAsyncTask(pat);
}
IAsyncResult BeiginGetDataAsync(object sender, EventArgs e, AsyncCallback async, object extractData)
{
svc = new Service1Client();
return svc.BeginGetData(656,async, extractData);
}
void EndDataRetrieveAsync(IAsyncResult ar)
{
Label1.Text = svc.EndGetData(ar);
}
and in page directive added Async="true"
In this scenario it is working fine. But from UI i'm not supposed to call the service methods directly. I need to call all service methods from a static class and from code behind file i need to invoke the static method.
In this scenario what exactlly do i need to do?
© Stack Overflow or respective owner