Ejemplo n.º 1
0
        private void CheckVersion()
        {
            PersistentStorageData data = PersistentStorageHelper.Load(PersistantStorageName);
            bool executeCheck          = false;

            if (data != null && data.Count > 0)
            {
                // get the last update date from the registry:
                lastUpdateCheck = data.GetDateTime("LastUpdateDate");
                sleepTime       = (int)data.GetUInt("SleepTimeBeforeUpdateCheck", SleepTimeBeforeUpdateCheck) * 1000;

                // check if update-check was performed at least one week ago:
                if (lastUpdateCheck.AddDays(PeriodBeforeUpdateCheck) < DateTime.Today)
                {
                    executeCheck = true;
                }
                else
                {
                    // prevent updating the date inside the registry:
                    lastUpdateCheck = DateTime.MinValue;
                }
            }
            else
            {
                executeCheck = true;
            }

            if (executeCheck && sleepTime != 0)
            {
                // start asynchronously new thread that will perform check and update the registry:
                Thread threadCheck = new Thread(PerformUpdateCheck);
                threadCheck.Start();
            }
        }