示例#1
0
        public ProgressTask(Action <IProgressPromise <TProgress> > task, bool runOnMainThread = false,
                            bool cancelable = false)
        {
            if (task == null)
            {
                throw new ArgumentNullException();
            }

            this._result = new ProgressResult <TProgress>(!runOnMainThread && cancelable);
            this._result.Callbackable().OnProgressCallback(OnProgressChanged);
            if (runOnMainThread)
            {
                this._action = WrapAction(() =>
                {
                    Executors.RunOnMainThread(() => task(_result), true);
                    _result.Synchronized().WaitForResult();
                });
            }
            else
            {
                this._action = WrapAction(() =>
                {
                    task(_result);
                    _result.Synchronized().WaitForResult();
                });
            }
        }
示例#2
0
 public virtual ISynchronizable Synchronized()
 {
     return(_result.Synchronized());
 }