示例#1
0
        /// <summary>
        /// Start a new recurrent action
        /// </summary>
        public static RecurentAction StartNew(Action actionToDo, long interval, int nbRepeat = 0, bool doActionOnCreate = true)
        {
            var created = new RecurentAction(actionToDo, interval, nbRepeat, doActionOnCreate);

            _savedReccurentActionStarted.Add(created);
            return(created);
        }
示例#2
0
 /// <summary>
 /// ASYNC - Call this method to start checking for updates every 2 hours, also check once immediately if
 /// Config.Instance.TechnicalCheckUpdateEveryXMin condition is met
 /// </summary>
 public void StartCheckingForUpdate()
 {
     // check for updates every now and then
     CheckRegularlyAction = RecurentAction.StartNew(() => {
         // Check for new updates
         if (!Config.Instance.GlobalDontCheckUpdates)
         {
             CheckForUpdate(false);
         }
     }, 1000 * 60 * Config.UpdateCheckEveryXMin, 0, Utils.IsLastCallFromMoreThanXMinAgo(UpdatedSoftName + "update", Config.UpdateCheckEveryXMin));
 }
示例#3
0
        /// <summary>
        /// ASYNC - Call this method to start checking for updates every 2 hours, also check once immediately if
        /// Config.Instance.TechnicalCheckUpdateEveryXMin condition is met
        /// </summary>
        public static void StartCheckingForUpdate()
        {
            // check for updates every now and then (2h)
            DateTime lastCheck;

            if (!DateTime.TryParseExact(Config.Instance.TechnicalLastCheckUpdate, "yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture, DateTimeStyles.None, out lastCheck))
            {
                lastCheck = DateTime.MinValue;
            }
            _checkEveryHourAction = RecurentAction.StartNew(() => {
                // Check for new updates
                if (!Config.Instance.GlobalDontCheckUpdates)
                {
                    CheckForUpdate(true);
                }
            }, 1000 * 60 * 120, 0, DateTime.Now.Subtract(lastCheck).TotalMinutes > Config.Instance.TechnicalCheckUpdateEveryXMin);
        }