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? -John =================================== This list is hosted by DevelopMentorĀ® http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com