void TranscodeComplete(IAsyncActionWithProgress <double> asyncInfo, AsyncStatus status) { asyncInfo.GetResults(); if (asyncInfo.Status == AsyncStatus.Completed) { // Display or handle complete info. } else if (asyncInfo.Status == AsyncStatus.Canceled) { // Display or handle cancel info. } else { // Display or handle error info. } }
public static IAsyncAction Wrap <TProgress>(IAsyncActionWithProgress <TProgress> action, int millisecondsCycle) { if (action is null) { throw new ArgumentNullException(nameof(action)); } if (millisecondsCycle < 0) { throw new ArgumentOutOfRangeException(nameof(millisecondsCycle)); } switch (action.Status) { case AsyncStatus.Canceled: return(AsyncAction.CreateCanceled()); case AsyncStatus.Completed: return(AsyncAction.CreateCompleted()); case AsyncStatus.Error: return(AsyncAction.CreateFault(action.ErrorCode)); } return(AsyncInfo.Run(async token => { token.Register(action.Cancel); while (action.Status == AsyncStatus.Started) { await Task.Delay(millisecondsCycle); token.ThrowIfCancellationRequested(); } switch (action.Status) { case AsyncStatus.Error: rethrow(action); return; case AsyncStatus.Completed: action.GetResults(); return; default: cancel(token); return; } })); }
private static void TranscodeComplete(IAsyncActionWithProgress <double> asyncInfo, AsyncStatus asyncStatus, Action callback, Action <IAsyncActionWithProgress <double> > faultCallback) { asyncInfo.GetResults(); if (asyncInfo.Status == AsyncStatus.Completed) { callback.SafeInvoke(); } else if (asyncInfo.Status == AsyncStatus.Canceled) { Telegram.Api.Helpers.Execute.ShowDebugMessage("Transcode canceled result " + asyncInfo.Status); faultCallback.SafeInvoke(asyncInfo); } else { Telegram.Api.Helpers.Execute.ShowDebugMessage("Transcode error result=" + asyncInfo.Status + " exception \n" + asyncInfo.ErrorCode); faultCallback.SafeInvoke(asyncInfo); } }
/* * Method for displaying the completion */ private void TranscodeComplete(IAsyncActionWithProgress <double> asyncInfo, AsyncStatus status) { asyncInfo.GetResults(); if (asyncInfo.Status == AsyncStatus.Completed) { // Display or handle complete info. System.Diagnostics.Debug.WriteLine("Conversion success!"); } else if (asyncInfo.Status == AsyncStatus.Canceled) { // Display or handle cancel info. System.Diagnostics.Debug.WriteLine("Conversion canceled!"); } else { // Display or handle error info. System.Diagnostics.Debug.WriteLine("Conversion failed!"); } }
void TranscodeComplete(IAsyncActionWithProgress <double> asyncInfo, AsyncStatus status) { asyncInfo.GetResults(); }