示例#1
0
 /// <summary>
 /// Replaces the schedule item if its not yet started, otherwises follows it with a new item.
 /// </summary>
 /// <param name="item">The replacement item.</param>
 /// <returns>The final item.</returns>
 public ASyncScheduleItem ReplaceOrFollowWith(ASyncScheduleItem item)
 {
     lock (Locker)
     {
         if (FollowUp != null)
         {
             return(FollowUp.ReplaceOrFollowWith(item));
         }
         if (Started)
         {
             if (Done)
             {
                 item.RunMe();
                 return(item);
             }
             else
             {
                 FollowUp = item;
                 return(item);
             }
         }
         else
         {
             MyAction = item.MyAction;
             FollowUp = item.FollowUp;
             return(this);
         }
     }
 }
示例#2
0
        /// <summary>
        /// Creates but does not start an async task.
        /// </summary>
        /// <param name="a">The action to launch async.</param>
        /// <param name="followUp">Optional followup task.</param>
        /// <returns>The created schedule item.</returns>
        public ASyncScheduleItem AddAsyncTask(Action a, ASyncScheduleItem followUp = null)
        {
            ASyncScheduleItem asyncer = new ASyncScheduleItem()
            {
                OwningEngine = this, MyAction = a, FollowUp = followUp
            };

            return(asyncer);
        }
示例#3
0
        /// <summary>
        /// Starts an async task.
        /// </summary>
        /// <param name="a">The action to launch async.</param>
        /// <param name="prio">Whether this action is considered important.</param>
        /// <returns>The scheduled item.</returns>
        public ASyncScheduleItem StartAsyncTask(Action a, bool prio = false)
        {
            ASyncScheduleItem asyncer = new ASyncScheduleItem()
            {
                OwningEngine = this, MyAction = a, UnImportant = !prio
            };

            asyncer.RunMe();
            return(asyncer);
        }
示例#4
0
 /// <summary>
 /// Tells the item to follow the current item with a new one.
 /// </summary>
 /// <param name="item">The follower item.</param>
 public void FollowWith(ASyncScheduleItem item)
 {
     lock (Locker)
     {
         if (Done)
         {
             item.RunMe();
         }
         else
         {
             FollowUp = item;
         }
     }
 }