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); }
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); }
/// <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(); } }
public void AddEvent(int threadId, ThreadEvent e) { ThreadEventList.GetList(Id, threadId).AddEvent(e); }