コード例 #1
0
        private DownloadMediaStillJob3 DownloadStillJob(AtemMediaCacheItem item)
        {
            var job = new DownloadMediaStillJob3(item.Index, VideoModeResolution._1080.GetByteCount());

            item.RawFrame = job.Result.ContinueWith <AtemFrame>(t =>
            {
                lock (item.JobLock)
                {
                    item.Job = null;

                    if (t.IsCompletedSuccessfully)
                    {
                        return(t.Result);
                    }
                }

                if (t.IsFaulted)
                {
                    Console.WriteLine("Still download failed {0}", t.Exception);
                    return(null);
                }

                return(null);
            });
            return(job);
        }
コード例 #2
0
ファイル: TransferJobMonitor.cs プロジェクト: LibAtem/AtemUI
        public StillDownloadJobEntry(string deviceId, DownloadMediaStillJob3 job, Action <DataTransferJob> notifyChanged) : base(deviceId, "Still")
        {
            _notifyChanged = notifyChanged;

            Index = job.StoreId;
            Job   = job;

            job.OnProgress += (sender, bytes, totalBytes) =>
            {
                ProgressPercent = ((double)bytes) / totalBytes;
                _notifyChanged(job);
            };
            CompletionTask = job.Result.ContinueWith(t =>
            {
                CompletedAt = DateTime.Now;

                if (t.IsCompletedSuccessfully)
                {
                    Success = true;
                    _notifyChanged(job);
                    return(t.Result);
                }

                if (t.IsFaulted)
                {
                    Status = $"Download failed: {t.Exception}";
                    Console.WriteLine("{0}: Still {1} {2}", deviceId, Index, Status);
                    _notifyChanged(job);
                    return(null);
                }

                _notifyChanged(job);
                return(null);
            });
        }