private void ProduceAsync() { for (int i = 0; i < 10; ++i) { service.Enqueue(async() => await DownloadFileAsync(i)); } service.Completed = true; }
public void AddTask(string url, string extension = default(string)) { logger.Debug($"Add download task ${url}"); Uri uriNormalized = new Uri(url); if (!indexFile.Contains(uriNormalized.AbsoluteUri) || (indexFile.Contains(uriNormalized.AbsoluteUri) && Redownload)) { indexFile.Cache(uriNormalized.AbsoluteUri, extension ?? Extension); if (AsyncMode) { service.Enqueue(() => Download(uriNormalized.AbsoluteUri, indexFile.Value(uriNormalized.AbsoluteUri))); } else { Download(uriNormalized.AbsoluteUri, indexFile.Value(uriNormalized.AbsoluteUri)); } } }