Пример #1
0
        private void ExecutionThread()
        {
            bool   shouldStayAlive    = true;
            JsTask currentlyExecuting = null;

            while (shouldStayAlive)
            {
                if (currentlyExecuting == null)
                {
                    lock (tasks)
                    {
                        currentlyExecuting = FirstToExecute();
                    }
                }

                if (currentlyExecuting != null)
                {
                    currentlyExecuting.Run();
                    currentlyExecuting = null;
                }
                else
                {
                    lock (aliveLock)
                        shouldStayAlive = alive;
                    if (shouldStayAlive)
                    {
                        newTaskEvent.WaitOne();
                    }
                }
            }
        }
Пример #2
0
 public override void QueueTask(JsTask task)
 {
     newTaskEvent.Reset();
     lock (tasks)
         _ = tasks.AddLast(task);
     newTaskEvent.Set();
 }
 public abstract void QueueTask(JsTask task);
Пример #4
0
 public JsTaskAwaiter(JsTask task)
 {
     _task = task;
 }