/// <summary> /// Creates a task factory using a <see cref="FiberTaskScheduler"/> /// initialized with the MonoBehaviour. /// </summary> /// <returns> /// The task factory. /// </returns> /// <param name='behaviour'> /// The MonoBehaviour. /// </param> public static TaskFactory CreateTaskFactory(this MonoBehaviour behaviour) { var scheduler = new FiberTaskScheduler(new UnityFiberScheduler(behaviour)); return(new TaskFactory(scheduler.CancellationToken, TaskCreationOptions.None, TaskContinuationOptions.None, scheduler)); }
/// <summary> /// Creates a task factory using a <see cref="FiberTaskScheduler"/> /// initialized with the MonoBehaviour. /// </summary> /// <returns> /// The task factory. /// </returns> /// <param name='behaviour'> /// The MonoBehaviour. /// </param> public static TaskFactory CreateTaskFactory(this MonoBehaviour behaviour) { var scheduler = new FiberTaskScheduler(new UnityFiberScheduler(behaviour)); return new TaskFactory(scheduler.CancellationToken, TaskCreationOptions.None, TaskContinuationOptions.None, scheduler); }
private IEnumerator TestFuncTaskCoroutine() { var scheduler = new FiberTaskScheduler(); var task = new YieldableTask(() => new YieldForSeconds(2)); task.Start(scheduler); while (!task.IsCompleted) yield return FiberInstruction.YieldToAnyFiber; }