示例#1
0
 /// <summary>
 ///     在UI线程中执行
 /// </summary>
 /// <param name="action"></param>
 /// <param name="args"></param>
 private void InvokeInUiThread <T>(Action <T> action, T args)
 {
     if (Synchronous == null)
     {
         action(args);
     }
     else
     {
         Synchronous.BeginInvokeInUiThread(action, args);
     }
 }
示例#2
0
        private void OnEnd(Task <TResult> task)
        {
            _task = null;
            switch (task.Status)
            {
            case TaskStatus.Faulted:
                //LogRecorder.Exception(task.Exception);
                Status = CommandStatus.Faulted;
                break;

            default:
                Status = CommandStatus.Succeed;
                break;
            }
            try
            {
                if (_endAction == null)
                {
                    return;
                }
                if (Synchronous == null)
                {
                    _endAction(Status, task.IsFaulted ? task.Exception : null, !task.IsFaulted ? task.Result : default(TResult));
                }
                else
                {
                    Synchronous.BeginInvokeInUiThread(_endAction, Status, task.IsFaulted ? task.Exception : null, !task.IsFaulted ? task.Result : default(TResult));
                }
            }
            catch (Exception ex)
            {
                LogRecorder.Exception(ex);
                Status = CommandStatus.Faulted;
            }
            finally
            {
                OnCanExecuteChanged();
            }
        }