Bug 13690 - Calling WebClient.CancelAsync(); UploadStringCompletedEventArgs.Cancelled is always false
Summary: Calling WebClient.CancelAsync(); UploadStringCompletedEventArgs.Cancelled is ...
Alias: None
Product: Class Libraries
Classification: Mono
Component: mscorlib ()
Version: master
Hardware: PC Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
Depends on:
Reported: 2013-08-01 14:32 UTC by Bryan Moulton
Modified: 2014-03-06 17:03 UTC (History)
3 users (show)

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:

Description Bryan Moulton 2013-08-01 14:32:18 UTC
In reference to case #42430...

I am trying to implement a sort of Timeout for the WebClient.UploadStringAsync using a System.Threading.Timer .

When my timer expired, I call the WebClient.CancelAsync() method. This cause an immediate callback to the UploadStringCompleted delegate method but the UploadStringCompletedEventArgs.Cancelled is always false and in UploadStringCompletedEventArgs.Error I have the following exception:

System.Threading.ThreadInterruptedException Thread Interrupted at at
(wrapper managed-to-native) System.Threading.WaitHandle:WaitOne_internal
(System.Threading.WaitHandle,intptr,int,bool) at
System.Threading.WaitHandle.WaitOne (Int32 millisecondsTimeout, Boolean
exitContext) [0x0002d] in
andle.cs:379 at System.Net.WebAsyncResult.WaitUntilComplete (Int32
timeout, Boolean exitContext) [0x0000d] in
ult.cs:167 at System.Net.HttpWebRequest.EndGetResponse (IAsyncResult
asyncResult) [0x0002e] in
est.cs:943 at System.Net.HttpWebRequest.GetResponse () [0x0000e] in
est.cs:957 at System.Net.WebClient.GetWebResponse (System.Net.WebRequest
request) [0x00000] in
s:1509 at System.Net.WebClient.ReadAll (System.Net.WebRequest request,
System.Object userToken) [0x00000] in
s:920 at System.Net.WebClient.UploadDataCore (System.Uri address,
System.String method, System.Byte[] data, System.Object userToken)
[0x00038] in

Same issue on Android.

Using the same code on Windows Phone 7.1, everything works fine, I have the e.Cancelled set on true and no exceptions in e.Error .
Comment 1 Bryan Moulton 2013-08-01 14:34:24 UTC
Version Information:

Xamarin Studio Version 4.0.10 (build 7) 

Installation UUID: 9e6e4221-0844-4908-8692-5e84ee5bd4b4

Runtime: Mono 3.2.0 ((no/7c7fcc7)

GTK 2.24.20 GTK# (

Package version: 302000000

Apple Developer Tools Xcode 4.6.3 (2068) Build 4H1503

Xamarin.Android Version: 4.8.0 (Business Edition)

Android SDK: /Developer/android-sdk-macosx 

Supported Android versions: 2.1 (API level 7) 2.2 (API level 8) 2.3 (API
level 10) 3.1 (API level 12) 4.0 (API level 14) 4.0.3 (API level 15) 4.2
(API level 17) 

Xamarin.iOS Version: (Business Edition) Hash: c9f7659 Branch:
Build date: 2013-18-07 21:36:03-0400
Comment 2 Marek Safar 2013-08-07 15:27:02 UTC
I cannot reproduce the issue. My simple test works as expected

		var wc = new WebClient ();
		wc.DownloadStringCompleted += (object sender, DownloadStringCompletedEventArgs e) => {
			Console.WriteLine (e.Cancelled);		

		wc.DownloadStringAsync (new Uri ("http://www.google.com"));
		wc.CancelAsync ();

		Console.ReadLine ();
Comment 3 Marek Safar 2014-03-06 17:03:33 UTC
-> no response