コード例 #1
0
        private void Run()
        {
            while (isRun)
            {
                if (queue.Count == 0 || isSuspend)
                {
                    resetEvent.WaitOne();
                    if (isSuspend)
                    {
                        state = ProcessState.Suspend;
                    }
                    else
                    {
                        state = ProcessState.Waiting;
                    }
                }
                else
                {
                    state = ProcessState.Processing;
                    StateItem item = null;
                    lock (queue)
                    {
                        item = queue.Dequeue();
                    }

                    try
                    {
                        IProcessDispatcher dispatcher = null;
                        if (context != null)
                        {
                            dispatcher = context.ProcessDispatcher;
                        }
                        else
                        {
                            dispatcher = new DefaultDispatcher();
                        }

                        StateChanged(item, dispatcher);
                    }
                    catch (Exception e)
                    {
                        Logger.Error(string.Format("{0}³ö´í¡£Ô­Òò£º{1}", GetType(), e.Message));
                    }
                }
            }
        }
コード例 #2
0
        private void Run()
        {
            while (isRun)
            {
                if (queue.Count == 0 || isSuspend)
                {
                    resetEvent.WaitOne();
                    if (isSuspend)
                        state = ProcessState.Suspend;
                    else
                        state = ProcessState.Waiting;
                }
                else
                {
                    state = ProcessState.Processing;
                    StateItem item = null;
                    lock (queue)
                    {
                        item = queue.Dequeue();
                    }

                    try
                    {
                        IProcessDispatcher dispatcher = null;
                        if (context != null)
                            dispatcher = context.ProcessDispatcher;
                        else
                            dispatcher = new DefaultDispatcher();
                        StateChanged(item, dispatcher);
                    }
                    catch (Exception e)
                    {
                        Logger.Error(string.Format("{0}�����ԭ��{1}", GetType(), e.Message));
                    }
                }
            }
        }