I’m trying to implement an API that performs some really lengthy tasks using a Web Service. I basically want the Web Service to kick off a thread that performs the lengthy task and leaves it running until it completes. The issue is because its an API I want it to be cross-platform. So my questions are the following:
- Is it possible to make asynchronous calls that do not require the client to be on .NET Framework? (It seems the Begin/End framework in place requires I return the .NET IASyncResult object) If so how can this be done? Totally unambiguous sample code would be amazingly helpful.
- Because there is no state preservation in a web service, can this thread be later recovered? In the event that the client wants to cancel the process this would be highly important.
This is a good place to start:
http://msdn.microsoft.com/en-us/library/aa480516.aspx
If you implement this pattern, from the client perspective, nothing changes. You can implement a second web method to check the status of any running jobs you queue up in your async method.
From the sample code, modified somewhat to give you an idea of what you need to do (I don’t expect this would compile):
As far as the client is concerned, they are calling a webmethod called LenghtyProcedure that will not return until the job is complete.