public bool StopEvent(uint eventId) { if (eventId == 0) { return(false); } lock (EventLock) { return(ActiveEventIds.Remove(eventId)); } }
protected void SchedulerThread() { while (State != DispatcherState.Terminated) { bool isEarlyWakening = true; Monitor.Enter(EventLock); if (EventList.Count == 0) { Monitor.Wait(EventLock); } else { int waitTime = EventList.Min.GetCycle(); if (waitTime > 0) { isEarlyWakening = Monitor.Wait(EventLock, waitTime); } else { isEarlyWakening = false; } } if (!isEarlyWakening && State != DispatcherState.Terminated) { SchedulerTask task = EventList.Min; // Get task with lowest expiration value EventList.Remove(task); if (!ActiveEventIds.Remove(task.TaskId)) // Is task still active { Monitor.Exit(EventLock); continue; } Monitor.Exit(EventLock); task.SetNotToExpire(); DispatcherManager.GameDispatcher.AddTask(task, true); } else { Monitor.Exit(EventLock); } } }