Beispiel #1
0
        public static bool SetFinalizeAndStart(TimerExecutorItem timerItem)
        {
            if (!timerItem.IsValidNonFinalize)
            {
                return(false);
            }
            timerItem.Finalize = () => { DestoyAndDelete(timerItem); };

            return(timerItem.CreateAndStart());
        }
Beispiel #2
0
 public static void DestoyAndDelete(TimerExecutorItem item)
 {
     if (item != null)
     {
         if (!string.IsNullOrWhiteSpace(item.Id) && _timers.Select(i => i.Key).Contains(item.Id))
         {
             Delete(item.Id);
         }
         item.Dispose();
     }
 }
Beispiel #3
0
        private static TimerExecutorItem _createUserTaskTimerBase(double delaySecond, int taskId, int sourceUserId, int targetPlanetId)
        {
            var timer = new TimerExecutorItem(TimerType.UserTask);

            timer.AdvancedData.Add(TimerAdvancedDataKeys.TaskId, taskId);
            timer.AdvancedData.Add(TimerAdvancedDataKeys.SourceUserId, sourceUserId);
            timer.AdvancedData.Add(TimerAdvancedDataKeys.TargetPlanetId, targetPlanetId);

            timer.Timer = new Timer(delaySecond * 1000)
            {
                AutoReset = false
            };
            return(timer);
        }
Beispiel #4
0
 private static bool _isEqualsKV(TimerExecutorItem item, TimerAdvancedDataKeys keyType, int keyValue)
 {
     return(_isEqualsKV <int>(item, keyType, keyValue));
 }
Beispiel #5
0
 private static bool _isEqualsKV <T>(TimerExecutorItem item, TimerAdvancedDataKeys keyType, T keyValue)
 {
     return(item.AdvancedData.ContainsKey(keyType) && Equals(item.AdvancedData[keyType], keyValue));
 }
Beispiel #6
0
 public static TimerExecutorItem AddOrUpdate(TimerExecutorItem item)
 {
     return(_timers.AddOrUpdateSimple(item.Id, item));
 }