private void BackgroundWorkerFileDescriptotDownload_DoWork(object sender, DoWorkEventArgs e) { Boolean continueDownload; int index = 0; String fileDescriptorId; if (!InitDone()) { return; } do { if (filesDescriptorToDownload.Count > 0) { // Check index if (index >= filesDescriptorToDownload.Count) { index = 0; } fileDescriptorId = filesDescriptorToDownload[index]; if (DownloadFileDescriptor(fileDescriptorId)) { filesDescriptorToDownload.Remove(fileDescriptorId); log.Debug("[BackgroundWorkerFileDescriptotDownload_DoWork] END - SUCCESS - fileDescriptorId:[{0}]", fileDescriptorId); Task task = new Task(() => { FileDescriptorAvailable.Invoke(this, new IdEventArgs(fileDescriptorId)); }); task.Start(); } else { // Download failed - we try for another FileDescriptor index++; log.Debug("[BackgroundWorkerFileDescriptotDownload_DoWork] END - FAILED - fileDescriptorId:[{0}]", fileDescriptorId); // FOR TEST PURPOSE filesDescriptorToDownload.Remove(fileDescriptorId); } } continueDownload = (filesDescriptorToDownload.Count > 0) && InitDone(); }while (continueDownload); }
internal void OnFileDescriptorAvailable(object sender, IdEventArgs args) { FileDescriptorAvailable.Raise(sender, args); }