示例#1
0
        internal static void Remove(ScheduledEvent scheduledEvent)
        {
            if (ScheduledEvents.Contains(scheduledEvent))
            {
                ScheduledEventsCount--;
                ScheduledEvents.Remove(scheduledEvent);
            }
            else
            {
                var errorMessage = $"[UnityTools.Scheduler] You are trying to remove a scheduled event, \n " +
                                   $"but there is no such scheduled event (already removed? forgot to make it null?).";

                Delegate[] invocationList = scheduledEvent.Action.GetInvocationList();
                errorMessage += $"\n Invocation actions of the scheduled event:";

                if (invocationList.Length > 0)
                {
                    for (int i = 0; i < invocationList.Length; i++)
                    {
                        errorMessage += $"\n {invocationList[i].Target} - {invocationList[i].Method}";
                    }
                }
                else
                {
                    errorMessage += $"\n no invocation actions.";
                }

                Debug.LogError(errorMessage);;
            }
        }
示例#2
0
        //--------------------------------------------------------------------------------------------------------------------
        // - Event Scheduler Main Routine
        //--------------------------------------------------------------------------------------------------------------------
        private static void Step()
        {
            LinkedListNode <Event> next;

            for (LinkedListNode <Event> scheduled = ScheduledEvents.First; scheduled != null;)
            {
                next = scheduled.Next;

                // For any event whose delay has expired or their triggering event has fired TRUE, execute and remove it
                if (scheduled.Value.Countdown() || (scheduled.Value.Trigger?.Invoke() ?? false))
                {
                    scheduled.Value.Action();
                    ScheduledEvents.Remove(scheduled);
                }
                scheduled = next;
            }
        }
示例#3
0
 public void Unschedule(ScheduledDomainEvent sched)
 {
     sched.timer.Dispose();
     ScheduledEvents.Remove(sched);
 }