OdessaGUIProject.UpdateChecker.CheckForUpdate C# (CSharp) Method

CheckForUpdate() private method

private CheckForUpdate ( ) : void
return void
        internal void CheckForUpdate()
        {
            // if this is our first time checking, save today's date and quit
            if (Properties.Settings.Default.LastUpdateCheckDate == DateTime.MinValue)
            {
                Logger.Info("This is our first time loading so don't check.");
                Properties.Settings.Default.LastUpdateCheckDate = DateTime.Today;
                Properties.Settings.Default.Save();
                return;
            }

            if (IsTimeToCheck() == false)
            {
                Logger.Info("Not time to check for updates yet");
                return;
            }

            try
            { // never crash just for checking if there's an update
                var bwUpdateCheck = new BackgroundWorker();
                bwUpdateCheck.DoWork += bwUpdateCheck_DoWork;
                bwUpdateCheck.RunWorkerCompleted += bwUpdateCheck_RunWorkerCompleted;
                bwUpdateCheck.RunWorkerAsync();
            }
            catch (Exception ex)
            {
                Logger.Error("Exception checking for update: " + ex);
            }
        }

Usage Example

Esempio n. 1
0
        private void MainForm_Shown(object sender, EventArgs e)
        {
            ShowEULA();

            #region show the tutorial dialog

            if (Settings.Default.ShowFirstRunScreenV2)
            {
                this.Activate();
                DisplayTutorial();
            }

            #endregion show the tutorial dialog

            #region check for updates
            var updateChecker = new UpdateChecker(IsSafeToPrompt);
            updateChecker.CheckForUpdate();
            #endregion check for updates

            #region Preload some things (disabled)

            /* don't do this until we can verify that it actually helps
            Thread jitter = new Thread(() =>
            {
                var wmp = new GenericPlayerControl();
                /*
                foreach (var type in Assembly.Load("MyHavyAssembly, Version=1.8.2008.8, Culture=neutral, PublicKeyToken=8744b20f8da049e3").GetTypes())
                {
                    foreach (var method in type.GetMethods(BindingFlags.DeclaredOnly |
                                        BindingFlags.NonPublic |
                                        BindingFlags.Public | BindingFlags.Instance |
                                        BindingFlags.Static))
                    {
                        System.Runtime.CompilerServices.RuntimeHelpers.PrepareMethod(method.MethodHandle);
                    }
                }
            });
            jitter.SetApartmentState(ApartmentState.STA);
            jitter.Priority = ThreadPriority.Lowest;
            jitter.Start();
            */

            #endregion Preload some things (disabled)
        }