public GMRTask <TResult> ContinueWith <TResult>(Func <GMRTask <T>, Task <TResult> > continuation)
        {
            if (this.IsCompletedSuccessfully || this.IsFaulted)
            {
                GMRTask <TResult> continueTaskSync = new GMRTask <TResult>();
                continuation(this).ContinueWith(t2 =>
                {
                    continueTaskSync.Result = t2.Result;

                    continueTaskSync.continuation?.Invoke(continueTaskSync);
                });

                return(continueTaskSync);
            }

            GMRTask <TResult>     continueTask = new GMRTask <TResult>();
            Action <GMRTask <T> > onContinue   = (t) =>
            {
                Task <TResult> awaitTask = continuation(t);
                awaitTask.ContinueWith((t2) =>
                {
                    continueTask.Result = t2.Result;

                    continueTask.continuation?.Invoke(continueTask);
                });
            };

            this.continuation += onContinue;
            return(continueTask);
        }
示例#2
0
        public GMRTask ContinueWith(Action <GMRTask> continuation)
        {
            GMRTask          continueTask = new GMRTask();
            Action <GMRTask> onContinue   = (t) =>
            {
                continuation(t);
                continueTask.continuation?.Invoke(continueTask);
            };

            this.continuation += onContinue;
            return(continueTask);
        }
示例#3
0
        public GMRTask ContinueWith(Func <GMRTask, Task> continuation)
        {
            GMRTask          continueTask = new GMRTask();
            Action <GMRTask> onContinue   = (t) =>
            {
                Task awaitTask = continuation(t);
                awaitTask.ContinueWith((t2) =>
                {
                    continueTask.continuation?.Invoke(continueTask);
                });
            };

            this.continuation += onContinue;
            return(continueTask);
        }
        public new GMRTask <T> ContinueWith(Action <GMRTask> continuation)
        {
            if (this.IsCompletedSuccessfully || this.IsFaulted)
            {
                continuation(this);
                return(this);
            }

            GMRTask <T>           continueTask = new GMRTask <T>();
            Action <GMRTask <T> > onContinue   = (t) =>
            {
                continuation(t);
                continueTask.continuation?.Invoke(continueTask);
            };

            this.continuation += onContinue;
            return(continueTask);
        }
        public GMRTask <TResult> ContinueWith <TResult>(Func <GMRTask <T>, TResult> continuation)
        {
            if (this.IsCompletedSuccessfully || this.IsFaulted)
            {
                GMRTask <TResult> continueTaskSync = new GMRTask <TResult>();
                continueTaskSync.Result = continuation(this);
                continueTaskSync.continuation?.Invoke(continueTaskSync);

                return(continueTaskSync);
            }

            GMRTask <TResult>     continueTask = new GMRTask <TResult>();
            Action <GMRTask <T> > onContinue   = (t) =>
            {
                var res = continuation(t);
                continueTask.Result = res;

                continueTask.continuation?.Invoke(continueTask);
            };

            this.continuation += onContinue;
            return(continueTask);
        }
 public GMRAwaiterT(GMRTask <T> task)
 {
     this.task = task;
 }
示例#7
0
 public GMRAwaiter(GMRTask task)
 {
     this.task = task;
 }