/// <summary> /// Starts a background task that runs on the UI-thread with time sharing. Shall be called from the UI-thread. /// </summary> /// <param name="task">The method of the task that will be executed on each frame update.</param> /// <param name="parameter">The parameter of the task method.</param> /// <returns>A reference to the interface of the created task.</returns> public static IUIBackgroundTask StartTimeSharingTask(UITimeSharingTaskMethod task, object parameter) { if (uiThread != null && RCThread.CurrentThread != uiThread) { throw new InvalidOperationException("UITaskManager.StartTimeSharingTask shall be called from the UI-thread!"); } if (calledFromUi) { throw new InvalidOperationException("Recursive call on UITaskManager!"); } if (task == null) { throw new ArgumentNullException("task"); } calledFromUi = true; uiThread = RCThread.CurrentThread; UITimeSharingTask taskData = new UITimeSharingTask(task, parameter); runningTimeSharingTasks.Add(taskData); calledFromUi = false; return(taskData); }
/// <summary> /// Constructs a UIParallelTask instance. /// </summary> public UITimeSharingTask(UITimeSharingTaskMethod taskProc, object parameter) { this.taskProc = taskProc; this.parameter = parameter; }
/// <summary> /// Starts a background task that runs on the UI-thread with time sharing. Shall be called from the UI-thread. /// </summary> /// <param name="task">The method of the task that will be executed on each frame update.</param> /// <returns>A reference to the interface of the created task.</returns> public static IUIBackgroundTask StartTimeSharingTask(UITimeSharingTaskMethod task) { return(StartTimeSharingTask(task, null)); }