/// <summary>
        /// 启动消息侦程序线程
        /// </summary>
        private void Start(MessageListener listener)
        {
            ThreadPool.STPStartInfo stp = new ThreadPool.STPStartInfo();
            stp.MaxStackSize     = MaxThreads;
            stp.MaxWorkerThreads = MaxThreads;
            ThreadPool.SmartThreadPool smartThreadpool = new ThreadPool.SmartThreadPool(stp);

            while (true)
            {
                MQMessage message = null;
                if (messageQueue.QueueConfig.isTransactional)
                {
                    MessageQueueTransaction tran = new MessageQueueTransaction();
                    message = new MQMessage(tran);
                    message.Begin();
                    message.messageContent = messageQueue.Receive(tran).Body.ToString();
                }
                else
                {
                    message = new MQMessage(null);
                    message.messageContent = messageQueue.Receive().Body.ToString();
                }
                System.Threading.Interlocked.Increment(ref Counter);
                while (Counter >= MaxThreads)
                {
                    System.Threading.Thread.Sleep(100);
                }
                smartThreadpool.QueueWorkItem(CallBack, message);
            }
        }
        /// <summary>
        /// 启动消息侦程序线程
        /// </summary>
        private void Start(MessageListener listener)
        {
            ThreadPool.STPStartInfo stp = new ThreadPool.STPStartInfo();
            stp.MaxStackSize = MaxThreads;
            stp.MaxWorkerThreads = MaxThreads;
            ThreadPool.SmartThreadPool smartThreadpool = new ThreadPool.SmartThreadPool(stp);

            while (true)
            {
                MQMessage message = null;
                if (messageQueue.QueueConfig.isTransactional)
                {
                    MessageQueueTransaction tran = new MessageQueueTransaction();
                    message = new MQMessage(tran);
                    message.Begin();
                    message.messageContent = messageQueue.Receive(tran).Body.ToString();
                }
                else
                {
                    message = new MQMessage(null);
                    message.messageContent = messageQueue.Receive().Body.ToString();
                }
                System.Threading.Interlocked.Increment(ref Counter);
                while (Counter >= MaxThreads)
                {
                    System.Threading.Thread.Sleep(100);
                }
                smartThreadpool.QueueWorkItem(CallBack, message);
            }
        }
Exemplo n.º 3
0
        public STPStartInfo(STPStartInfo stpStartInfo)
            : base(stpStartInfo)
        {
            _idleTimeout      = stpStartInfo.IdleTimeout;
            _minWorkerThreads = stpStartInfo.MinWorkerThreads;
            _maxWorkerThreads = stpStartInfo.MaxWorkerThreads;
#if !(WINDOWS_PHONE)
            _threadPriority = stpStartInfo.ThreadPriority;
#endif
            _performanceCounterInstanceName = stpStartInfo.PerformanceCounterInstanceName;
            _enableLocalPerformanceCounters = stpStartInfo._enableLocalPerformanceCounters;
            _threadPoolName       = stpStartInfo._threadPoolName;
            _areThreadsBackground = stpStartInfo.AreThreadsBackground;
#if !(_SILVERLIGHT) && !(WINDOWS_PHONE)
            _apartmentState = stpStartInfo._apartmentState;
#endif
        }
Exemplo n.º 4
0
	    public STPStartInfo(STPStartInfo stpStartInfo)
            : base(stpStartInfo)
        {
            _idleTimeout = stpStartInfo.IdleTimeout;
            _minWorkerThreads = stpStartInfo.MinWorkerThreads;
            _maxWorkerThreads = stpStartInfo.MaxWorkerThreads;
#if !(WINDOWS_PHONE)
            _threadPriority = stpStartInfo.ThreadPriority;
#endif
            _performanceCounterInstanceName = stpStartInfo.PerformanceCounterInstanceName;
            _enableLocalPerformanceCounters = stpStartInfo._enableLocalPerformanceCounters;
            _threadPoolName = stpStartInfo._threadPoolName;
            _areThreadsBackground = stpStartInfo.AreThreadsBackground;
#if !(_SILVERLIGHT) && !(WINDOWS_PHONE)
            _apartmentState = stpStartInfo._apartmentState;
#endif
        }