How are you implementing BeginWebService? By default Visual Studio
generates *Async methods to execute web service methods asynchronously,
which is then "ended" via the call to the callback. An asynchronous call
can be canceled via the CancelAsync method.
-- Peter
On Wed, 15 Aug 2007 09:48:55 -0500, John Bush <[EMAIL PROTECTED]> wrote:
>When using Begin/End methods to asynchronously invoke a method, my
>understanding is that you always need to call the End method or
>resources will be leaked.
>
>But let's say I'm calling a web service and want the user to be able
>to cancel it:
>
>IAsyncResult result = proxy.BeginWebService(...);
>
>while (!result.IsCompleted)
>{
> Thread.Sleep(500);
>
> if (backgroundWorker.CancellationPending)
> {
> // we need to make sure EndWebService gets called
> ThreadPool.QueueUserWorkItem(delegate { proxy.EndWebService
(result); });
> return;
> }
>}
>
>proxy.EndWebService(result);
>
>Would that be the correct way to go about it? If the user wants to
>cancel, I need to bail out of the loop, but I also need to make sure
>EndWebService gets called. I don't want to make the user wait for the
>web service call to complete, so is it ok to have the thread pool make
>the EndWebService call?
===================================
This list is hosted by DevelopMentorĀ® http://www.develop.com
View archives and manage your subscription(s) at http://discuss.develop.com