Avoid race condition in WebClient.IsBusy. (#42076)
authorTheodore Tsirpanis <12659251+teo-tsirpanis@users.noreply.github.com>
Thu, 17 Sep 2020 15:58:21 +0000 (18:58 +0300)
committerGitHub <noreply@github.com>
Thu, 17 Sep 2020 15:58:21 +0000 (17:58 +0200)
src/libraries/System.Net.WebClient/src/System/Net/WebClient.cs

index 8849777..c02b169 100644 (file)
@@ -213,7 +213,7 @@ namespace System.Net
 
         public RequestCachePolicy? CachePolicy { get; set; }
 
-        public bool IsBusy => _asyncOp != null;
+        public bool IsBusy => Volatile.Read(ref _callNesting) > 0;
 
         protected virtual WebRequest GetWebRequest(Uri address)
         {