Пример #1
0
 public static void Schedule(ScheduleDelegate d)
 {
     lock(schedule)
     {
         schedule.Add(d);
     }
 }
Пример #2
0
        public bool RegisterSchedule(EnumSchedule schedule, ScheduleDelegate scheduleDelegate)
        {
            if (_disableSchedule)
            {
                return(false);
            }
            var config = ScheduleConfig.Instance.GetEntity(schedule);

            if (config == null)
            {
                SystemlogMgr.Error("Schedule register", "can't find schedule config,id:" + (int)schedule);
                return(false);
            }
            ScheduleInfo info = new ScheduleInfo(scheduleDelegate, config);

            _rwl.AcquireWriterLock(Timeout.Infinite);
            try
            {
                _scheduleInfoDict.Add((int)schedule, info);
                LogHelper.Insert(schedule.ToString() + " register success.", LogType.Info);
            }
            finally
            {
                _rwl.ReleaseWriterLock();
            }
            return(true);
        }