Пример #1
0
 public Thread(bool startThread = true)
 {
     staticId++;
     id = staticId;
     if (startThread)
     {
         thread = new System.Threading.Thread(new ThreadStart(Start));
         thread.Start();
     }
     fps = new FPSCounter();
     ThreadEventList.AddThread(Id);
 }
Пример #2
0
        public static List <ThreadEvent> GetAllEvent(int threadId)
        {
            List <ThreadEvent> list = new List <ThreadEvent>();

            for (int i = 0; i < threads.Count; i++)
            {
                if (threads[i] != threadId)
                {
                    ThreadEventList threadEventList = threadList[threads[i]][threadId];
                    ThreadEvent     e = threadEventList.ReadEvent();
                    while (e != null)
                    {
                        list.Add(e);
                        e = threadEventList.ReadEvent();
                    }
                }
            }
            return(list);
        }
Пример #3
0
        /// <summary>
        /// 更新
        /// </summary>
        /// <param name="state"></param>
        virtual public void Update(object state = null)
        {
            if (exitAllFlag)
            {
                timer.Dispose();
                return;
            }
            fps.Update();

            //清除没已读的事件
            ThreadEventList.ClearEventList(Id);

            //接受来自 GameThread 的事件
            List <ThreadEvent> list = ThreadEventList.GetAllEvent(Id);

            for (int i = 0; i < list.Count; i++)
            {
                this.Dispatch(list[i]);
                list[i].Dispose();
            }
        }
Пример #4
0
 public void AddEvent(int threadId, ThreadEvent e)
 {
     ThreadEventList.GetList(Id, threadId).AddEvent(e);
 }