Example #1
0
        private bool RemovedScheduledItemAt(int index)
        {
            bool result;

            if (index >= 0)
            {
                ScheduledItem scheduledItem = this.m_ScheduledItems[index];
                this.m_ScheduledItems.RemoveAt(index);
                scheduledItem.OnItemUnscheduled();
                result = true;
            }
            else
            {
                result = false;
            }
            return(result);
        }
Example #2
0
        public void Unschedule(IScheduledItem item)
        {
            ScheduledItem sItem = item as ScheduledItem;

            if (sItem != null)
            {
                if (m_TransactionMode)
                {
                    if (m_UnscheduleTransactions.Contains(sItem))
                    {
                        throw new ArgumentException("Cannot unschedule scheduled function twice" + sItem);
                    }
                    else if (m_ScheduleTransactions.Remove(sItem))
                    {
                        // A item has been scheduled then unscheduled in the same transaction. which is valid.
                    }
                    else if (m_ScheduledItems.Contains(sItem))
                    {
                        // Only add it to m_UnscheduleTransactions if it is in m_ScheduledItems.
                        // if it was successfully removed from m_ScheduleTransaction we are fine.
                        m_UnscheduleTransactions.Add(sItem);
                    }
                    else
                    {
                        throw new ArgumentException("Cannot unschedule unknown scheduled function " + sItem);
                    }
                }
                else
                {
                    if (!PrivateUnSchedule(sItem))
                    {
                        throw new ArgumentException("Cannot unschedule unknown scheduled function " + sItem);
                    }
                }

                sItem.OnItemUnscheduled(); // Call OnItemUnscheduled immediately after successful removal even if we are in transaction mode
            }
        }