Exemple #1
0
		public static void Run(bool bForceUI, Form fOptParent)
		{
			DateTime dtNow = DateTime.UtcNow, dtLast;
			string strLast = Program.Config.Application.LastUpdateCheck;
			if(!bForceUI && (strLast.Length > 0) && TimeUtil.TryDeserializeUtc(
				strLast, out dtLast))
			{
				if(CompareDates(dtLast, dtNow) == 0) return; // Checked today already
			}
			Program.Config.Application.LastUpdateCheck = TimeUtil.SerializeUtc(dtNow);

			UpdateCheckParams p = new UpdateCheckParams(bForceUI, fOptParent);
			if(!bForceUI) // Async
			{
				// // Local, but thread will continue to run anyway
				// Thread th = new Thread(new ParameterizedThreadStart(
				//	UpdateCheckEx.RunPriv));
				// th.Start(p);

				try
				{
					ThreadPool.QueueUserWorkItem(new WaitCallback(
						UpdateCheckEx.RunPriv), p);
				}
				catch(Exception) { Debug.Assert(false); }
			}
			else RunPriv(p);
		}
Exemple #2
0
		private static void RunPriv(object o)
		{
			UpdateCheckParams p = (o as UpdateCheckParams);
			if(p == null) { Debug.Assert(false); return; }

			IStatusLogger sl = null;
			try
			{
				if(p.ForceUI)
				{
					Form fStatusDialog;
					sl = StatusUtil.CreateStatusDialog(p.Parent, out fStatusDialog,
						KPRes.UpdateCheck, KPRes.CheckingForUpd + "...", true, true);
				}

				List<UpdateComponentInfo> lInst = GetInstalledComponents();
				List<string> lUrls = GetUrls(lInst);
				Dictionary<string, List<UpdateComponentInfo>> dictAvail =
					DownloadInfoFiles(lUrls, sl);
				if(dictAvail == null) return; // User cancelled

				MergeInfo(lInst, dictAvail);

				bool bUpdAvail = false;
				foreach(UpdateComponentInfo uc in lInst)
				{
					if(uc.Status == UpdateComponentStatus.NewVerAvailable)
					{
						bUpdAvail = true;
						break;
					}
				}

				if(sl != null) { sl.EndLogging(); sl = null; }

				if(bUpdAvail || p.ForceUI)
					ShowUpdateDialogAsync(lInst, p.ForceUI);
			}
			catch(Exception) { Debug.Assert(false); }
			finally
			{
				try { if(sl != null) sl.EndLogging(); }
				catch(Exception) { Debug.Assert(false); }
			}
		}
Exemple #3
0
        public static void Run(bool bForceUI, Form fOptParent)
        {
            DateTime dtNow = DateTime.Now, dtLast;
            string strLast = Program.Config.Application.LastUpdateCheck;
            if(!bForceUI && (strLast.Length > 0) && TimeUtil.TryDeserializeUtc(
                strLast, out dtLast))
            {
                if(CompareDates(dtLast, dtNow) == 0) return; // Checked today already
            }
            Program.Config.Application.LastUpdateCheck = TimeUtil.SerializeUtc(dtNow);

            UpdateCheckParams p = new UpdateCheckParams(bForceUI, fOptParent);
            if(!bForceUI) // Async
            {
                // // Local, but thread will continue to run anyway
                // Thread th = new Thread(new ParameterizedThreadStart(
                //	UpdateCheckEx.RunPriv));
                // th.Start(p);

                try
                {
                    ThreadPool.QueueUserWorkItem(new WaitCallback(
                        UpdateCheckEx.RunPriv), p);
                }
                catch(Exception) { Debug.Assert(false); }
            }
            else RunPriv(p);
        }