Exemplo n.º 1
0
        public async void ProcessVideos()
        {
            foreach (var file in RarList.FileList)
            {
                Task <bool> rarTask       = null;
                Task <bool> thumbnailTask = null;
                Task <bool> coverTask     = null;

                try
                {
                    var videoTasks = new List <Task>();
                    if (CompressToRar)
                    {
                        rarTask = VideoUtil.ToRAR(file.Path, file.FileName);
                        videoTasks.Add(rarTask);
                    }
                    if (GetThumbnail)
                    {
                        thumbnailTask = VideoCover.GetSnapshot(file.Path, file.FileName);
                        videoTasks.Add(thumbnailTask);
                    }
                    if (GetCover)
                    {
                        coverTask = VideoCover.DownloadCovers(file.FileName);
                        videoTasks.Add(coverTask);
                    }

                    await Task.WhenAll(videoTasks);

                    if (rarTask != null)
                    {
                        file.RarStatus = await rarTask ? "OK" : "Error";
                    }
                    if (thumbnailTask != null)
                    {
                        file.ThumbnailStatus = await thumbnailTask ? "OK" : "Error";
                    }
                    if (coverTask != null)
                    {
                        file.CoverStatus = await coverTask ? "OK" : "Error";
                    }
                }
                catch (Exception ex)
                {
                    Message = ex.InnerException != null ? ex.InnerException.Message : ex.Message;
                }
            }
        }