/// <summary> /// Creates and starts a task. /// </summary> public static SystemTask StartNew(SystemTaskFactory factory, Action action, SystemCancellationToken cancellationToken, SystemTaskCreationOptions creationOptions, SystemTaskScheduler scheduler) { var runtime = CoyoteRuntime.Current; if (runtime.SchedulingPolicy is SchedulingPolicy.None || scheduler.GetType() != SystemTaskScheduler.Default.GetType()) { return(factory.StartNew(action, cancellationToken, creationOptions, scheduler)); } return(runtime.TaskFactory.StartNew(action, cancellationToken, runtime.TaskFactory.CreationOptions | creationOptions, runtime.TaskFactory.Scheduler)); }
/// <summary> /// Creates and starts a task. /// </summary> public static SystemTasks.Task <TResult> StartNew <TResult>(SystemTaskFactory factory, Func <object, TResult> function, object state, SystemCancellationToken cancellationToken, SystemTaskCreationOptions creationOptions, SystemTaskScheduler scheduler) { var runtime = CoyoteRuntime.Current; if (runtime.SchedulingPolicy is SchedulingPolicy.None || scheduler.GetType() != SystemTaskScheduler.Default.GetType()) { return(factory.StartNew(function, state, cancellationToken, creationOptions, scheduler)); } return(runtime.TaskFactory.StartNew(function, state, cancellationToken, runtime.TaskFactory.CreationOptions | creationOptions, runtime.TaskFactory.Scheduler)); }
/// <summary> /// Creates and starts a task. /// </summary> public static SystemTasks.Task <TResult> StartNew <TResult>(SystemTaskFactory factory, Func <object, TResult> function, object state, SystemTaskCreationOptions creationOptions) => StartNew(factory, function, state, SystemCancellationToken.None, creationOptions, SystemTaskScheduler.Default);
/// <summary> /// Creates and starts a task. /// </summary> public static SystemTask StartNew(SystemTaskFactory factory, Action <object> action, object state, SystemTaskCreationOptions creationOptions) => StartNew(factory, action, state, SystemCancellationToken.None, creationOptions, SystemTaskScheduler.Default);