Example #1
0
        private int Process()
        {
            CLongRunningTask task = null;

            lock (m_TaskLockObj)
            {
                if (m_vTasks.Count <= 0)
                {
                    return(0);
                }
                task = m_vTasks.Dequeue();
            }
            if (task == null)
            {
                return(1);
            }
            if (task.IsShutdownTask())
            {
                return(-1);
            }

            ETaskExecResult eResult = task.Execute();

            switch (eResult)
            {
            case ETaskExecResult.eTaskExecResult_Ok:
            {
                lock (m_FinishedLockObj)
                {
                    m_vFinishedTasks.Add(task);
                }
                break;
            }

            case ETaskExecResult.eTaskExecResult_Failed:
            {
                //SystemLogger.Log.Error("Task Execute Failed!Finished it! ");
                lock (m_FinishedLockObj)
                {
                    m_vFinishedTasks.Add(task);
                }
                break;
            }

            case ETaskExecResult.eTaskExecResult_Pedding:
            {
                lock (m_TaskLockObj)
                {
                    m_vTasks.Enqueue(task);
                }
                break;
            }

            default:
                return(1);
            }
            return(1);
        }
Example #2
0
 public void AddTask(CLongRunningTask pTask)
 {
     lock (m_TaskLockObj)
     {
         m_vTasks.Enqueue(pTask);
     }
     // - Process some pending finished tasks
     //Tick(0);
 }