public Worker() { Current = this; waitingTimeout = Context.Model.GetSettings().WaitingTimeout; thread = new Thread(new ThreadStart(Proc)); thread.Name = "Worker"; thread.IsBackground = true; thread.Start(); }
public Context() { Current = this; Utils.CheckOrGenerateUniqueId(); refreshCounter = Utils.GetRefreshCounter(); mainThreadID = Thread.CurrentThread.GetHashCode(); memTimer.Interval = 1000; // execute after one second memTimer.Elapsed += new System.Timers.ElapsedEventHandler(memTimer_Elapsed); counterTimer.Interval = 5*60*1000; // execute every 5 minutes counterTimer.Elapsed += new System.Timers.ElapsedEventHandler(counterTimer_Elapsed); LoadSettings(); model.Init(); menu = new Menu(); sysTray = new SysTray("", icon, menu); notifyIcon = sysTray.m_notifyIcon; notifyIcon.DoubleClick += new EventHandler(notifyIcon_DoubleClick); server = new Server(); server.Start(); menu.RebuildMenu(); UpdateTrayIcon(); worker = new Worker(); model.Start(); ThreadExit += new EventHandler(OnThreadExit); memTimer.Start(); if (Utils.IsRunningFirstTime()) { // open help page try { Process.Start(System.IO.Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath) + "\\Help.html"); } catch (Exception) { // opening help file was not so important ... } if (MessageBox.Show("XRefresh is running for the first time.\nDo you want to configure it now? [recommended]\n\nNote:\nYou can do it anytime later. Just right click on XRefresh icon in the traybar and select 'Configuration' from context menu.", "XRefresh Configuration during first start", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { ShowConfiguration(this, new EventArgs()); } } }