Asynchronous Web Service and cancelability

N

Nathan

I have a loop that requests blocks of data through a web service, and
inserts each in turn into a SQL Server CE database.

It sounds like a good candidate for asynchronous web service calls.

So I would call Begin with a call back. When the callback is called, insert
result into the database.

However, the user could decide to quit and download no further data. This
doesn't sound safe as there are still threads running. If the form is
closed, the callback could no longer be valid. Worse yet, as we know about
the Pocket PC platform, those threads could keep running if the program is
closed. (No thread.abort available.)

Any suggestions?

Nathan
 
A

Alex Feinman [MVP]

You need to call Abort() on the web service proxy class for every pending
request.
 
N

Nathan

Alex Feinman said:
You need to call Abort() on the web service proxy class for every pending
request.

Thanks. I found what I needed there.

Nathan
--

Abort cancels a synchronous XML Web service request. Since a synchronous
request will block the thread until the response has been processed you must
call Abort from a separate thread. Calling Abort will cause a WebException
to be thrown from the XML Web service method call. The WebException.Status
property will have the value WebExceptionStatus.RequestCanceled. To abort an
asynchronous call, you need to cast the IAsyncResult returned from the Begin
method to a WebClientAsyncResult and call the WebClientAsyncResult.Abort
method.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top