public IDownloadedResource Download(RemoteResource remoteResource) { IProgressBar progressBar = _progressBar.CreateChildDownloadProgress(remoteResource.Url.OriginalString); try { Interlocked.Increment(ref _activeDownloadCount); return(DownloadResource(remoteResource, progressBar).Result); } catch (Exception ex) { if (ex is SocketException || ex is HttpRequestException) { NoInternetConnection(); } throw; } finally { progressBar.Close(); Interlocked.Decrement(ref _activeDownloadCount); } }