예제 #1
0
        protected virtual void OnScheduleTick(object sender, ScheduleTickEventArgs e)
        {
            bool isDirty  = false;
            var  schedule = (HSchedule)sender;

            try
            {
                string oldpacket = e.Packet.ToString();
                ScheduleTick?.Invoke(this, e);
                string newPacket = e.Packet.ToString();

                if (oldpacket != newPacket ||
                    e.Interval > 0 && schedule.Interval != e.Interval)
                {
                    isDirty = true;
                }
            }
            catch { e.Cancel = true; }
            finally
            {
                schedule.IsRunning = !e.Cancel;

                if (isDirty || e.Cancel)
                {
                    UpdateItem(schedule);
                }
            }
        }
예제 #2
0
 private void OnScheduleTick(ScheduleTickEventArgs e)
 {
     try
     {
         if (Cycles != 0 && _currentCycle >= Cycles)
         {
             IsRunning = false;
             e.Cancel  = true;
         }
         ScheduleTick?.Invoke(this, e);
     }
     catch { e.Cancel = true; }
     finally
     {
         if (e.Cancel)
         {
             IsRunning = false;
         }
     }
 }