コード例 #1
0
        private async Task <bool> CheckForUpdates()
        {
            if (Dispatcher.Invoke(() => HasUpdate && !App.Settings.ShouldCheckUpdates))
            {
                return(true); //dont check again if we already found one recently
            }
            Substrate.SetSystemWorkingStatus("Checking for updates...");

            try
            {
                var client = new GitHubClient(new ProductHeaderValue(nameof(Reclaimer), App.AppVersion));
                var latest = await client.Repository.Release.GetLatest("Gravemind2401", nameof(Reclaimer));

                App.Settings.LastUpdateCheck = DateTime.Now;
                App.Settings.LatestRelease   = new AppRelease(latest);
                App.Settings.Save();

                await Dispatcher.InvokeAsync(() => CoerceValue(HasUpdateProperty));

                return(true);
            }
            catch (Exception ex)
            {
                Substrate.LogError("Error checking for updates", ex);
                return(false);
            }
            finally
            {
                Substrate.ClearSystemWorkingStatus();
            }
        }