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; } }
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; } }
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; } }