internal void AddTask(TaskBase task)
        {
            lock (taskList)
            {
                taskList.Add(task);

                if (TaskSortingSystem == UnityThreading.TaskSortingSystem.ReorderWhenAdded ||
                    TaskSortingSystem == UnityThreading.TaskSortingSystem.ReorderWhenExecuted)
                {
                    ReorderTasks();
                }
            }
            dataEvent.Set();
        }
Beispiel #2
0
        /// <summary>
        /// Dispatches the given task to the target Dispatcher (default: the main Dispatcher).
        /// This method will wait for the task completion or the timeout.
        /// </summary>
        /// <param name="taskBase">The task to process at the dispatchers thread.</param>
        /// <param name="timeOutSeconds">Time in seconds after the waiting process will stop.</param>
        public void DispatchAndWait(TaskBase taskBase, float timeOutSeconds)
        {
            var task = this.Dispatch(taskBase);

            task.WaitForSeconds(timeOutSeconds);
        }
Beispiel #3
0
        /// <summary>
        /// Dispatches the given task to the target Dispatcher (default: the main Dispatcher).
        /// This method will wait for the task completion.
        /// </summary>
        /// <param name="taskBase">The task to process at the dispatchers thread.</param>
        public void DispatchAndWait(TaskBase taskBase)
        {
            var task = this.Dispatch(taskBase);

            task.Wait();
        }
Beispiel #4
0
 /// <summary>
 /// Dispatches the given task to the target Dispatcher (default: the main Dispatcher).
 /// </summary>
 /// <param name="taskBase">The task to process at the dispatchers thread.</param>
 /// <returns>The new task.</returns>
 public TaskBase Dispatch(TaskBase taskBase)
 {
     return(targetDispatcher.Dispatch(taskBase));
 }