コード例 #1
0
 public void Download(MultiMirrorFileDownloadSpec spec) {
     spec.Start();
     try {
         while (true) {
             var host = _mirrorStrategy.GetHost();
             if (TryDownload(spec, host))
                 break;
             Thread.Sleep(MillisecondsTimeout);
         }
     } catch (Exception) {
         spec.Fail();
         throw;
     }
 }
コード例 #2
0
 public void Download(MultiMirrorFileDownloadSpec spec, CancellationToken token) {
     spec.Start();
     try {
         while (true) {
             token.ThrowIfCancellationRequested();
             var host = _mirrorStrategy.GetHost();
             if (TryDownload(spec, host))
                 break;
             Thread.Sleep(MillisecondsTimeout);
         }
     } catch (Exception) {
         spec.Fail();
         throw;
     }
 }
コード例 #3
0
 public async Task DownloadAsync(MultiMirrorFileDownloadSpec spec) {
     spec.Start();
     try {
         while (true) {
             var host = _mirrorStrategy.GetHost();
             spec.UpdateHost(host);
             if (await TryDownloadAsync(spec, host).ConfigureAwait(false))
                 break;
             await Task.Delay(MillisecondsTimeout).ConfigureAwait(false);
         }
     } catch (Exception) {
         spec.Fail();
         throw;
     }
 }