Apache.NMS.ActiveMQ.Threads.PooledTaskRunner.RunTask C# (CSharp) Method

RunTask() private method

private RunTask ( ) : void
return void
        internal void RunTask()
        {
            lock(runable)
            {
                queued = false;
                if(_shutdown)
                {
                    iterating = false;
                    return;
                }
                iterating = true;
            }

            // Don't synchronize while we are iterating so that
            // multiple wakeup() calls can be executed concurrently.
            bool done = false;
            try
            {
                for(int i = 0; i < maxIterationsPerRun; i++)
                {
                    if(!task.Iterate())
                    {
                        done = true;
                        break;
                    }
                }
            }
            finally
            {
                lock(runable)
                {
                    iterating = false;
                    if(_shutdown)
                    {
                        queued = false;
                    }
                    else
                    {
                        // If we could not iterate all the items
                        // then we need to re-queue.
                        if(!done)
                        {
                            queued = true;
                        }

                        if(queued)
                        {
                            ThreadPool.QueueUserWorkItem(new WaitCallback(Run), this);
                        }
                    }
                }
            }
        }

Usage Example

Example #1
0
        public void Run(Object o)
        {
            PooledTaskRunner p = o as PooledTaskRunner;

            p.runningThread = System.Threading.Thread.CurrentThread;
            try
            {
                p.RunTask();
            }
            finally
            {
                p.runningThread = null;
            }
        }
All Usage Examples Of Apache.NMS.ActiveMQ.Threads.PooledTaskRunner::RunTask