StartRoutine() public static method

Scheduled the routine to run (on the main thread)
public static StartRoutine ( IEnumerator coroutine ) : Coroutine
coroutine IEnumerator
return UnityEngine.Coroutine
Exemplo n.º 1
0
        protected void RunAsCoroutine()
        {
            Status = TaskStatus.Pending;

            TaskManager.StartRoutine(new TaskManager.CoroutineCommand
            {
                Coroutine  = _routine,
                OnComplete = OnRoutineComplete
            });
        }
Exemplo n.º 2
0
        /// <summary>
        /// Like continue runs after the host task is complete but returns a new task with a converted result
        /// </summary>
        /// <typeparam name="T">new conversion type</typeparam>
        /// <param name="func">conversion function</param>
        /// <returns></returns>
        public UnityTask <T> ConvertTo <T>(Func <UnityTask <TResult>, T> func)
        {
            var task = new UnityTask <T>(TaskStrategy.Custom);

            if (IsCompleted)
            {
                task.Result    = func(this);
                task.Exception = Exception;
                task.Status    = Status;
            }
            else
            {
                TaskManager.StartRoutine(ConvertToAsync(task, func));
            }
            return(task);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Adds a timeout to the task. Will raise an exception if still running
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="self"></param>
        /// <param name="seconds"></param>
        /// <param name="onTimeout"></param>
        /// <returns></returns>
        public static T AddTimeout <T>(this T self, int seconds, Action <AsyncTask> onTimeout = null) where T : AsyncTask
        {
            TaskManager.StartRoutine(TimeOutAsync(self, seconds, onTimeout));

            return(self);
        }