Beispiel #1
0
        // 工作线程每一轮循环的实质性工作
        public override void Worker()
        {
            try
            {
                PropertyTask task       = null;
                int          nRestCount = 0;

                // 取出第一个元素
                if (this.m_lock.TryEnterWriteLock(m_nLockTimeout) == false)
                {
                    throw new LockException("锁定尝试中超时");
                }
                try
                {
                    if (this._tasks.Count == 0)
                    {
                        return;
                    }
                    task = this._tasks[0];
                    this._tasks.RemoveAt(0);
                    nRestCount = this._tasks.Count;
                }
                finally
                {
                    this.m_lock.ExitWriteLock();
                }

                try
                {
                    lock (syncRoot)
                    {
                        this._currentTask = task;
                    }

                    if (task.LoadData() == false)
                    {
                        return;
                    }

                    task.ShowData();

                    lock (syncRoot)
                    {
                        this._currentTask = null;
                    }
                }
                finally
                {
                    if (nRestCount > 0)
                    {
                        this.Activate();
                    }
                }
            }
            catch (Exception ex)
            {
                Program.MainForm.WriteErrorLog("PropertyTaskList Worker() 出现异常: " + ExceptionUtil.GetDebugText(ex));
                Program.MainForm.ReportError("dp2circulation 调试信息", "PropertyTaskList Worker() 出现异常: " + ExceptionUtil.GetDebugText(ex));
            }
        }