private void UpdateTaskRun(Config config, Action <bool, string> update) { var autoUpdateSubTime = DateTime.Now; var autoUpdateGeoTime = DateTime.Now; Thread.Sleep(60000); Utils.SaveLog("UpdateTaskRun"); var updateHandle = new UpdateHandle(); while (true) { var dtNow = DateTime.Now; if (config.autoUpdateSubInterval > 0) { if ((dtNow - autoUpdateSubTime).Hours % config.autoUpdateSubInterval == 0) { updateHandle.UpdateSubscriptionProcess(config, true, (bool success, string msg) => { update(success, msg); if (success) { Utils.SaveLog("subscription" + msg); } }); autoUpdateSubTime = dtNow; } Thread.Sleep(60000); } if (config.autoUpdateInterval > 0) { if ((dtNow - autoUpdateGeoTime).Hours % config.autoUpdateInterval == 0) { updateHandle.UpdateGeoFile("geosite", config, (bool success, string msg) => { update(false, msg); if (success) { Utils.SaveLog("geosite" + msg); } }); updateHandle.UpdateGeoFile("geoip", config, (bool success, string msg) => { update(false, msg); if (success) { Utils.SaveLog("geoip" + msg); } }); autoUpdateGeoTime = dtNow; } } Thread.Sleep(1000 * 3600); } }
private void UpdateTaskRun(Config config, Action <bool, string> update) { var updateHandle = new UpdateHandle(); while (true) { Thread.Sleep(60000); if (config.autoUpdateInterval <= 0) { continue; } Utils.SaveLog("UpdateTaskRun"); updateHandle.UpdateSubscriptionProcess(config, true, (bool success, string msg) => { update(success, msg); if (success) { Utils.SaveLog("subscription" + msg); } }); Thread.Sleep(60000); updateHandle.UpdateGeoFile("geosite", config, (bool success, string msg) => { update(false, msg); if (success) { Utils.SaveLog("geosite" + msg); } }); updateHandle.UpdateGeoFile("geoip", config, (bool success, string msg) => { update(false, msg); if (success) { Utils.SaveLog("geoip" + msg); } }); Thread.Sleep(1000 * 3600 * config.autoUpdateInterval); } }
private void UpdateTaskRun(Config config) { var updateHandle = new UpdateHandle(); while (true) { Utils.SaveLog("UpdateTaskRun"); Thread.Sleep(60000); if (config.autoUpdateInterval <= 0) { continue; } updateHandle.UpdateGeoFile("geosite", config, (bool success, string msg) => { _updateUI(false, msg); if (success) { Utils.SaveLog("geosite" + msg); } }); Thread.Sleep(60000); updateHandle.UpdateGeoFile("geoip", config, (bool success, string msg) => { _updateUI(false, msg); if (success) { Utils.SaveLog("geoip" + msg); } }); Thread.Sleep(1000 * 3600 * config.autoUpdateInterval); } }