Beispiel #1
0
 int PostTimerTask(TaskNode taskNode, int delay)
 {
     taskNode.delay     = delay;
     taskNode.startTime = DateTime.Now;
     taskQue.timerWriteList.Add(taskNode);
     return(0);
 }
Beispiel #2
0
        int ProcessTaskNodeData(TaskNode node)
        {
            if (node.processDataCallBack != null)
            {
                node.processDataCallBack(node.data);
            }

            if (node.releaseDataCallBack != null)
            {
                node.releaseDataCallBack(node.data);
            }

            TaskMsg taskMsg = node.msg;

            switch (taskMsg)
            {
            case TaskMsg.TMSG_QUIT:
                quitSem.Set();
                return(1);

            case TaskMsg.TMSG_PAUSE:
                pauseSem.WaitOne();
                pauseSem.Reset();
                break;
            }

            return(0);
        }
        public override int PostTask(TaskNode taskNode, int delay = 0)
        {
            if (unityUpdate.taskPump == null)
            {
                return(-1);
            }

            return(unityUpdate.taskPump.PostTask(taskNode, delay));
        }
Beispiel #4
0
        public int Pause()
        {
            TaskNode node = new TaskNode(TaskMsg.TMSG_PAUSE);

            if (PostTask(node, 0) != 0)
            {
                return(-1);
            }

            return(0);
        }
        public override int PostTask(TaskCallBack processDataCallBack, TaskCallBack releaseDataCallBack, object taskData, TaskMsg msg = TaskMsg.TMSG_DATA, int delay = 0)
        {
            if (unityUpdate.taskPump == null)
            {
                return(-1);
            }

            TaskNode taskNode = new TaskNode(processDataCallBack, releaseDataCallBack, taskData, msg);

            return(unityUpdate.taskPump.PostTask(taskNode, delay));
        }
Beispiel #6
0
        public int Quit()
        {
            Continue();

            TaskNode node = new TaskNode(TaskMsg.TMSG_QUIT);

            if (PostTask(node, 0) != 0)
            {
                return(-1);
            }

            quitSem.WaitOne();
            quitSem.Reset();
            return(0);
        }
Beispiel #7
0
        int PostCommonTask(TaskNode taskNode, int delay)
        {
            int ret = 0;

            taskNode.delay = delay;
            if (delay != 0)
            {
                taskNode.startTime = DateTime.Now;
            }

            if (delay == 0)
            {
                taskQue.writeList.Add(taskNode);
            }
            else
            {
                taskQue.timerWriteList.Add(taskNode);
            }

            return(ret);
        }
Beispiel #8
0
        public int PostTask(TaskNode taskNode, int delay = 0)
        {
            int ret = 0;

            Monitor.Enter(taskQue.lockobj);

            switch (taskNode.msg)
            {
            case TaskMsg.TMSG_TIMER_START:
            {
                ret = PostTimerTask(taskNode, -2000);
            }
            break;

            case TaskMsg.TMSG_TIMER_RUN:
            {
                ret = PostTimerTask(taskNode, delay);
            }
            break;

            case TaskMsg.TMSG_TIMER_STOP:
            {
                ret = PostCommonTask(taskNode, -1000);
            }
            break;

            default:
                ret = PostCommonTask(taskNode, delay);
                break;
            }

            Monitor.Exit(taskQue.lockobj);

            //设置任务处理可读信号
            readSem.Set();

            return(ret);
        }