日期:2014-05-17  浏览次数:20887 次

while循环消耗内存的问题
本帖最后由 viki117 于 2012-03-08 16:21:19 编辑

while (ThreadStatus.thread_running == m_status)
            {
                mMessage msg = null;
                lock (m_queueLock)
                {
                    if (t_msgQueue_high.Count > 0)
                    {
                        msg = t_msgQueue_high[0];
                        t_msgQueue_high.RemoveAt(0);
                    }
                    else if (t_msgQueue_Ordinary.Count > 0)
                    {
                        msg = t_msgQueue_Ordinary[0];
                        t_msgQueue_Ordinary.RemoveAt(0);
                    }
                    else if (t_msgQueue_low.Count > 0)
                    {
                        msg = t_msgQueue_low[0];
                        t_msgQueue_low.RemoveAt(0);
                    }
                    else
                    {
                        Thread.Sleep(1);
                        continue;
                    }
                }

                if (