コード例 #1
0
        /// <summary>
        /// Fire the event with the given arguments, with a callback action to indicate delayed completion.
        /// </summary>
        /// <param name="schedule">The scheduler of relevance.</param>
        /// <param name="args">The arguments.</param>
        /// <param name="complete">Action to fire when completed.</param>
        public void Fire(Scheduler schedule, T args, Action complete)
        {
            List <FreneticEventWaiter> fews = new List <FreneticEventWaiter>();

            for (int i = 0; i < Handlers.Count; i++)
            {
                FreneticEventArgs <T> fargs = new FreneticEventArgs <T>()
                {
                    PriorityPosition = Handlers[i].Priority,
                    Context          = args,
                    ScheduleHelper   = schedule
                };
                FreneticEventWaiter few = Handlers[i].Fire(fargs);
                if (few != null)
                {
                    fews.Add(few);
                }
            }
            if (fews.Count == 0)
            {
                complete();
                return;
            }
            schedule.StartAsyncTask(() =>
            {
                foreach (FreneticEventWaiter few in fews)
                {
                    few.MREFinalComplete.WaitOne();
                }
                schedule.ScheduleSyncTask(complete);
            });
        }
コード例 #2
0
 /// <summary>
 /// Fire the event with the given arguments.
 /// </summary>
 /// <param name="schedule">The scheduler of relevance.</param>
 /// <param name="args">The arguments.</param>
 public void Fire(Scheduler schedule, T args)
 {
     for (int i = 0; i < Handlers.Count; i++)
     {
         FreneticEventArgs <T> fargs = new FreneticEventArgs <T>()
         {
             PriorityPosition = Handlers[i].Priority,
             Context          = args,
             ScheduleHelper   = schedule
         };
         Handlers[i].Fire(fargs);
     }
 }
コード例 #3
0
        /// <summary>
        /// Fires the event, potentially returning a waiter.
        /// </summary>
        /// <param name="fea">The arguments to the event.</param>
        /// <returns>A waiter if needed.</returns>
        public FreneticEventWaiter FireWait(FreneticEventArgs <T> fea)
        {
            FreneticEventWaiter few = new FreneticEventWaiter()
            {
                Schedule = fea.ScheduleHelper
            };

            fea.ScheduleHelper.StartAsyncTask(() =>
            {
                FireWaiter(fea, few);
                few.MREFirst.Set();
                if (few.Used && few.AutoComplete)
                {
                    few.Complete();
                }
            });
            few.MREFirst.WaitOne();
            if (few.Used)
            {
                return(few);
            }
            return(null);
        }
コード例 #4
0
 /// <summary>
 /// Fires the event, not returning a waiter.
 /// </summary>
 /// <param name="fea">The arguments to the event.</param>
 /// <returns>No waiter.</returns>
 public FreneticEventWaiter FireNoWait(FreneticEventArgs <T> fea)
 {
     FireAction(fea);
     return(null);
 }