Ejemplo n.º 1
0
        void FetchMethod <TDelegate> (string name, Type[] types, ref TDelegate field) where TDelegate : class
        {
            var method = scheduler.GetType().GetMethod(name,
                                                       BindingFlags.Instance | BindingFlags.Public,
                                                       null,
                                                       types,
                                                       null);

            if (method == null)
            {
                return;
            }
            field = Delegate.CreateDelegate(typeof(TDelegate), scheduler, method) as TDelegate;
            Console.WriteLine("Created delegate for " + name);
        }
Ejemplo n.º 2
0
        /// <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));
        }
Ejemplo n.º 3
0
        /// <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));
        }