Bug 18488 - WebClient CancelAsync doesn't cancel
Summary: WebClient CancelAsync doesn't cancel
Status: RESOLVED FIXED
Alias: None
Product: Class Libraries
Classification: Mono
Component: System ()
Version: 3.2.x
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: marcos.henrich
URL:
Depends on:
Blocks:
 
Reported: 2014-03-20 06:35 UTC by David Lambert
Modified: 2014-06-03 11:08 UTC (History)
3 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description David Lambert 2014-03-20 06:35:53 UTC
Hi,

So I'm trying to send a file like the following under OSX.

var webClient = new WebClient();
var waitHandle = new ManualResetEvent(false);
webClient.UploadFileCompleted += (sender, args) => waitHandle.Set();
cancellationToken.Register(webClient.CancelAsync);
webClient.UploadFileAsync(new Uri(url), "PUT", filePath);
waitHandle.WaitOne(); 

When I trigger cancellation on the cancellation token, CancelAsync is called but the upload goes on and the UploadfileCompleted is also not fired at cancellation.

Best regards,

David
Comment 1 David Lambert 2014-03-20 06:41:05 UTC
This targets Mono / .Net 4.0.
Comment 2 marcos.henrich 2014-06-03 11:08:26 UTC
Hi David,

I could not reproduce the bug on master. Have a look on how I tried to reproduce it: https://gist.github.com/esdrubal/d6447be5566371766a27

Here is a pull request with tests that covers WebClient Upload cancellation:
https://github.com/mono/mono/pull/1079