Advertisement
Guest User

Untitled

a guest
Jul 7th, 2015
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.23 KB | None | 0 0
  1.         public void Download(string repositoriesFileName, string folder, string language)
  2.         {
  3.             downloads.Clear();
  4.             string archiveName;
  5.             string fullPath;
  6.             int currentStreams = 0;
  7.             int maxStreams = 2;
  8.             foreach (string repository in RepositoriesReader.ReadRepositoreis(repositoriesFileName))
  9.             {
  10.                 if (isStopped) break;
  11.                 if (finished.Contains(repository)) continue;
  12.                 archiveName = repository.Replace('/', '-') + ".zip";
  13.                 fullPath = string.Format(folder, archiveName);
  14.                 if (currentStreams == maxStreams)
  15.                 {
  16.                     finishedTask = Task.WhenAny(downloads).Result;
  17.                     downloads.Remove(finishedTask);
  18.                     finished.Add(Patterns.GetRepositoryName(finishedTask.Result));
  19.                     currentStreams--;
  20.                 }
  21.                 downloads.Add(loader.DownloadZipAsync(repository, fullPath));
  22.                 currentStreams++;
  23.             }
  24.             if (!isStopped)
  25.             {
  26.                 Task.WaitAll(downloads.ToArray());
  27.                 Serializer.ClearDownloader(language);
  28.             }
  29.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement