示例#1
0
 private void DropList_Drop(object sender, DragEventArgs e)
 {
     ThreadPool.QueueUserWorkItem(a => {
         var stringData = e.Data.GetData(typeof(string)) as string;
         var songs      = stringData?.Split('\n');
         if (songs == null)
         {
             return;
         }
         try {
             foreach (var result in
                      songs.Select(songin => songin?.Split('/'))
                      .Select(splitted => splitted?[splitted.Length - 1]))
             {
                 ThreadPool.QueueUserWorkItem(async aa => {
                     var song = await _spotify.DownloadSongInformationAsync(result);
                     Songs.Add(song);
                     _downloader.Add(song);
                 });
             }
         } catch (Exception ex) {
             Debug.WriteLine(ex);
         }
     });
 }
示例#2
0
 // 添加任务
 private static void AddJob(DownloadJob job)
 {
     job.DownloadCompleted += Job_DownloadCompleted;
     job.DownloadCancel    += Job_DownloadCancel;
     DownloadJobs.Add(job);
     Downloader.Add(job);
 }