public async void Execute() { if (KoobooUpgrade.IsAutoUpgrade) { var hours = DateTime.Now.Hour; // only do it in the midnight of current computer zone. if (hours == 2 || hours == 3 || hours == 4) { await KoobooUpgrade.Upgrade(); } } }
private async void Upgrade_Click(object sender, RoutedEventArgs e) { //防止重复点击 if (!IsUpgrade) { IsUpgrade = true; try { Action action = () => { SetUpgradeBtnStatus(); }; await this.Dispatcher.BeginInvoke(action); await KoobooUpgrade.Upgrade(DownloadProgressChanged); } finally { IsUpgrade = false; } } }