Beispiel #1
0
        private static void PerformTask()
        {
            lock (ActionQueue._lock)
            {
                if (ActionQueue.task == null)
                {
                    ActionQueue.task = Task.Factory.StartNew(delegate()
                    {
                        System.Threading.Thread.CurrentThread.Name ??= "公共队列任务线程";

                        while (!queue.IsEmpty && ActionQueue.queue.TryDequeue(out WaitAction waitAction))
                        {
                            if (waitAction != null && !waitAction.IsCompleted)
                            {
                                using (waitAction)
                                {
                                    waitAction.Run();
                                    ContinueWith?.Invoke(waitAction);
                                }
                            }
                        }

                        ActionQueue.task = null;
                    }, TaskCreationOptions.LongRunning).ContinueWith(delegate(Task i)
                    {
                        i.Dispose();
                    });
                }
            }
        }
Beispiel #2
0
 private void YieldFocuser()
 {
     MRS.Reset();
     MRS.WaitOne();
     ContinueWith?.Invoke();
 }