예제 #1
0
        internal void Run()
        {
            _isRequestedToStop = false;

            while (!_isRequestedToStop)
            {
                MVVQueueCommand cmd = _queue.Pop();

                if (cmd != null)
                {
                    _isBusy = true;

                    try
                    {
                        cmd.worker = this;

                        cmd.ExecuteCommand();
                        cmd.OnComplete();
                    }
                    catch (Exception ex)
                    {
                        cmd.OnError(ex);
                        _isBusy = false;

                        Console.WriteLine(ex.ToString());

                        throw ex;
                    }
                    _isBusy = false;
                }

                Thread.Sleep(1);
            }
        }
예제 #2
0
        public void Push(MVVQueueCommand cmd)
        {
            lock (lockObject)
            {
                commands.Add(cmd);
                //commands.Push(new BasicQueueItem(cmd));

                _leftToGo++;
                _totalAdded++;

                InvokeEvents();
            }
        }
예제 #3
0
        internal MVVQueueCommand Pop()
        {
            lock (lockObject)
            {
                /*
                 * MVVQueueCommand result = commands.Pop();
                 *
                 * if (result != null)
                 * {
                 *  _leftToGo--;
                 *
                 *  InvokeEvents();
                 *  return result;
                 * }
                 * return null;
                 * //MVVQueueCommand result
                 */
                if (commands.Count > 0)
                {
                    int             index = commands.Count - 1;
                    MVVQueueCommand cmd   = commands[index];

                    commands.RemoveAt(index);

                    //_currentCommands++;

                    _leftToGo--;



                    return(cmd);
                }

                InvokeEvents();

                return(null);
            }

            return(null);
        }