/// <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); }
/// <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)); }
/// <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); }