protected virtual void OnProcessingCompleted(Bitmap processedImage) { ProcessingCompleted?.Invoke(this, new ImageProcessingEventArgs() { Image = processedImage }); }
private void OnProcessingCompleted(object sender, ProcessingCompletedEventArgs e) { var status = JobStatus.Complete; WriteStatus(e.ProcessingRequest, status, e.ResultBody); ProcessingCompleted?.Invoke(this, e); }
public async Task <IAsyncActionWithProgress <double> > StartTranscodeMedia(StorageFile inputFile, StorageFile outFile, MediaEncodingProfile profile) { MediaTranscoder transcoder = new MediaTranscoder(); PrepareTranscodeResult prepareOp = await transcoder.PrepareFileTranscodeAsync(inputFile, outFile, profile); if (prepareOp.CanTranscode) { var transcodeOp = prepareOp.TranscodeAsync(); transcodeOp.Progress += new AsyncActionProgressHandler <double>((asyncInfo, e) => { ProcessingProgressChanged?.Invoke(this, e); }); transcodeOp.Completed += new AsyncActionWithProgressCompletedHandler <double>((asyncInfo, status) => { asyncInfo.GetResults(); switch (status) { case AsyncStatus.Canceled: ProcessingCanceled?.Invoke(this, new EventArgs()); break; case AsyncStatus.Completed: ProcessingCompleted?.Invoke(this, new EventArgs()); break; case AsyncStatus.Started: break; case AsyncStatus.Error: default: ProcessingError?.Invoke(this, "转码失败"); break; } }); return(transcodeOp); } else { switch (prepareOp.FailureReason) { case TranscodeFailureReason.CodecNotFound: ProcessingError?.Invoke(this, "转码失败:找不到编解码器"); break; case TranscodeFailureReason.InvalidProfile: ProcessingError?.Invoke(this, "转码失败:配置文件无效"); break; default: ProcessingError?.Invoke(this, "转码失败:未知错误"); break; } return(null); } }
public async Task <IAsyncOperationWithProgress <TranscodeFailureReason, double> > StartCompositionDashMedia(IList <StorageFile> inputFiles, StorageFile outFile, MediaEncodingProfile profile = null) { MediaComposition composition = new MediaComposition(); var clip = await MediaClip.CreateFromFileAsync(inputFiles.FirstOrDefault(x => x.Name == "video.m4s")); composition.Clips.Add(clip); var backgroundTrack = await BackgroundAudioTrack.CreateFromFileAsync(inputFiles.FirstOrDefault(x => x.Name == "audio.m4s")); composition.BackgroundAudioTracks.Add(backgroundTrack); IAsyncOperationWithProgress <TranscodeFailureReason, double> saveOperation = null; if (profile != null) { saveOperation = composition.RenderToFileAsync(outFile, MediaTrimmingPreference.Fast, profile); } else { saveOperation = composition.RenderToFileAsync(outFile, MediaTrimmingPreference.Fast); } saveOperation.Progress = new AsyncOperationProgressHandler <TranscodeFailureReason, double>((info, progress) => { ProcessingProgressChanged?.Invoke(this, progress); }); saveOperation.Completed = new AsyncOperationWithProgressCompletedHandler <TranscodeFailureReason, double>((info, status) => { if (status == AsyncStatus.Canceled) { ProcessingCanceled?.Invoke(this, new EventArgs()); return; } var results = info.GetResults(); if (results != TranscodeFailureReason.None || status != AsyncStatus.Completed) { ProcessingError?.Invoke(this, "合并失败:未知错误"); } else { ProcessingCompleted?.Invoke(this, new EventArgs()); } }); return(saveOperation); }
public CrawlingQueueItem ChangeStatus(CrawlingStatuses status) { if (Status != status) { Status = status; switch (status) { case CrawlingStatuses.InProxyQueue: QueuedInProxyQueue?.Invoke(); break; case CrawlingStatuses.InLocalQueue: QueuedInLocalQueue?.Invoke(); break; case CrawlingStatuses.Downloading: DownloadStarted?.Invoke(); break; case CrawlingStatuses.Downloaded: DownloadCompleted?.Invoke(); break; case CrawlingStatuses.Processing: ProcessingStarted?.Invoke(); break; case CrawlingStatuses.Processed: ProcessingCompleted?.Invoke(); break; default: throw new NotSupportedException(); } } return(this); }
protected virtual void OnProcessingCompleted(TEvent e) { ProcessingCompleted?.Invoke(this, e); }
void IDisposable.Dispose() { ProcessingCompleted?.Invoke(this, EventArgs.Empty); }
/// <summary> /// Invoked when the processing of a <see cref="ProcessingRequest"/> completes successfully /// </summary> /// <param name="request"><see cref="ProcessingRequest"/> provided to <see cref="ProcessAsync(ProcessingRequest, CancellationToken)"/></param> /// <param name="result">Optional result of processing</param> protected virtual void OnProcessingCompleted(ProcessingRequest request, string result = null) { ProcessingCompleted?.Invoke(this, new ProcessingCompletedEventArgs(request, result)); }