I'm looking to make a series of web service calls (all to the same service, different paramters passed each time).
I've been doing a bit of reading about PageAsyncTasks, and they look right, but not sure how to pass a parameter down to each call to the service. Much simplified example below - real world will be looping around and changing the parameter before registering each task to be performed:
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
int myParameter = 1;
var task = new PageAsyncTask(BeginRequest, EndRequest, null, null, true);
RegisterAsyncTask(task);
}
IAsyncResult BeginRequest(Object sender, EventArgs e, AsyncCallback cb, object state)
{
var service = new ServiceClient();
return service.BeginServiceCall(<How to get the parameter to the async call?>,
cb, service);
}
... End request etc....
The 4th argument ("state" in our example) can be used to pass in an object as a parameter to your task. If you have more than one parameter that needs to be passed in, you'll want to create a seperate class (a DataTransferObject for example) that hold all of these parameters that would be used by your task.