Ejemplo n.º 1
0
 private static void RunWorkItemTask(IWorkItem todo)
 {
     try
     {
         RuntimeContext.SetExecutionContext(todo.GrainContext);
         todo.Execute();
     }
     finally
     {
         RuntimeContext.ResetExecutionContext();
     }
 }
Ejemplo n.º 2
0
 private static void RunWorkItemTask(IWorkItem todo, TaskScheduler sched)
 {
     try
     {
         RuntimeContext.SetExecutionContext(todo.SchedulingContext, sched);
         todo.Execute();
     }
     finally
     {
         RuntimeContext.ResetExecutionContext();
     }
 }
Ejemplo n.º 3
0
 private static void RunWorkItemTask(IWorkItem todo, TaskScheduler sched)
 {
     try
     {
         RuntimeContext.SetExecutionContext(todo.SchedulingContext, sched);
         todo.Execute();
     }
     finally
     {
         RuntimeContext.ResetExecutionContext();
     }
 }
        void RunWorker()
        {
            while (!shutdown)
            {
                lock (locker) {
                    while (taskQueue.Count == 0 && !shutdown)
                    {
                        Monitor.Wait(locker);
                    }
                }

                while (taskQueue.Count > 0)
                {
                    bool shouldCancel = (shutdown && shutdownMode.Equals(ShutdownMode.CancelQueuedTasks));
                    if (shouldCancel)
                    {
                        break;
                    }

                    IWorkItem task = null;
                    lock (locker) {
                        if (taskQueue.Count > 0)
                        {
                            task = taskQueue.Dequeue();
                        }
                    }
                    if (task != null)
                    {
                        task.Execute();
                    }
                }
            }

            foreach (IWorkItem task in taskQueue)
            {
                task.Cancel("Shutdown");
            }

            shutdownCompleted = true;
        }
Ejemplo n.º 5
0
 public void DoTask(IWorkItem workItem)
 {
     Task.Run(() => { workItem.Execute(); });
 }