예제 #1
0
 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.
     }
 }
예제 #2
0
        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);
     }
 }
예제 #4
0
 /*
  *  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!");
     }
 }
예제 #5
0
 void TranscodeComplete(IAsyncActionWithProgress <double> asyncInfo, AsyncStatus status)
 {
     asyncInfo.GetResults();
 }