This is a good place to start:
http://msdn.microsoft.com/en-us/library/aa480516.aspx
If you implement this template, nothing changes from the point of view of the client. You can implement the second web method to check the status of any running jobs queued in your asynchronous method.
From the example code slightly modified to give you an idea of ββwhat you need to do (I don't expect this to compile):
[WebService]
public class AsyncWebService : System.Web.Services.WebService
{
public delegate string LengthyProcedureAsyncStub(
int milliseconds, MyState state);
public string LengthyProcedure(int milliseconds, MyState state)
{
while(state.Abort == false)
{
}
return state.Abort ? "Aborted" : "Success";
}
public class MyState
{
public Guid JobID = Guid.NewGuid();
public object previousState;
public LengthyProcedureAsyncStub asyncStub;
public bool Abort = false;
}
[ System.Web.Services.WebMethod ]
public IAsyncResult BeginLengthyProcedure(int milliseconds,
AsyncCallback cb, object s)
{
LengthyProcedureAsyncStub stub
= new LengthyProcedureAsyncStub(LengthyProcedure);
MyState ms = new MyState();
ms.previousState = s;
ms.asyncStub = stub;
return stub.BeginInvoke(milliseconds, cb, ms);
}
[ System.Web.Services.WebMethod ]
public string EndLengthyProcedure(IAsyncResult call)
{
MyState ms = (MyState)call.AsyncState;
return ms.asyncStub.EndInvoke(call);
}
[WebMethod]
public void StopJob(Guid jobID)
{
MyState state = GetStateFromServiceWideContainer(jobID);
state.Abort = true;
}
}
For the client, they invoke a web method called LenghtyProcedure, which will not return until the job is completed.