Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void Download(string repositoriesFileName, string folder, string language)
- {
- downloads.Clear();
- string archiveName;
- string fullPath;
- int currentStreams = 0;
- int maxStreams = 2;
- foreach (string repository in RepositoriesReader.ReadRepositoreis(repositoriesFileName))
- {
- if (isStopped) break;
- if (finished.Contains(repository)) continue;
- archiveName = repository.Replace('/', '-') + ".zip";
- fullPath = string.Format(folder, archiveName);
- if (currentStreams == maxStreams)
- {
- finishedTask = Task.WhenAny(downloads).Result;
- downloads.Remove(finishedTask);
- finished.Add(Patterns.GetRepositoryName(finishedTask.Result));
- currentStreams--;
- }
- downloads.Add(loader.DownloadZipAsync(repository, fullPath));
- currentStreams++;
- }
- if (!isStopped)
- {
- Task.WaitAll(downloads.ToArray());
- Serializer.ClearDownloader(language);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement