Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 4
0
        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);
        }
Ejemplo n.º 5
0
        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);
        }
Ejemplo n.º 6
0
 public GMRAwaiterT(GMRTask <T> task)
 {
     this.task = task;
 }
Ejemplo n.º 7
0
 public GMRAwaiter(GMRTask task)
 {
     this.task = task;
 }