コード例 #1
0
        private void Work()
        {
            try
            {
                SubThreadChanger = ThreadChanger.GetSubThreadChanger();
                while (true)
                {
                    QueueTask task = null;

                    lock (_locker)
                    {
                        if (_tasks.Count > 0)
                        {
                            task = _tasks.Dequeue();
                            if (task == null)  // empty task = signal for stop
                            {
                                return;
                            }
                        }
                    }

                    if (task != null)
                    {
                        DoTask(task);
                    }
                    else
                    {
                        // Queue is empty, waiting for a new task
                        _wh.WaitOne();
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.Log(LogLevel.Warn, ex, "An abnormal exception occurs in a TaskQueue that has not been catched properly");
            }
        }
コード例 #2
0
 public ISubThreadChanger GetSubThreadChanger() => ThreadChanger.GetSubThreadChanger();