private void frmWaitMessage_Load(object sender, EventArgs e) { lblDisplayMessage.Text = usedisplaymessage; pBarPleaseWait.Style = ProgressBarStyle.Continuous; updateTimer = new System.Windows.Forms.Timer(); updateTimer.Tick += new EventHandler(updateTimer_Tick); updateTimer.Interval = 1; updateTimer.Start(); }
protected override void WndProc(ref Message m) { Console.WriteLine(m.ToString()); if (m.Msg == WM_SYSCOMMAND && (m.WParam.ToInt32() & 0xfff0) == SC_SCREENSAVE) { _ssTimer.Start(); this.WriteLog("Screensaver active. Stop timer..."); StopTimer(); CommitLastLog(); } base.WndProc(ref m); }
// I have no idea why just calling BringToFront does not work, but it does not. Go figure private void bringDialogToFront() { try { TopMost = true; System.Windows.Forms.Timer t = new System.Windows.Forms.Timer { Interval = 100 }; t.Tick += (s, e) => { TopMost = false; t.Stop(); }; t.Start(); } catch (Exception e) { // in case somebody closes the dialog before the timer fires up Debug.WriteLine("CreateIssue.bringDialogToFront() - exception: " + e.Message); } }
static void System_Windows_Forms_Timer(object secVal) { Console.WriteLine("start T3"); DateTime start = new DateTime(); DateTime stop = new DateTime(); long startTicks = 0; long stopTicks = 0; long difference = 0; Exception timerException = null; //int count_val = count; //!!!TimerEndInfo timerEnd = new TimerEndInfo(); try { Stopwatch stopwatch = new Stopwatch(); // Запускаем внутренний таймер объекта Stopwatch stopwatch.Start(); start = DateTime.Now; startTicks = DateTime.Now.Ticks; //////////////////////////////////////////////////////////////////////////////////////////////////////// TimerWF.Interval = (int)secVal; // TimerWF.Tick += new EventHandler(SomeFuncForTimerWF); TimerWF.Enabled = true; TimerWF.Start(); //////////////////////////////////////////////////////////////////////////////////////////////////////// stopwatch.Stop(); // Останавливаем внутренний таймер объекта Stopwatch stop = DateTime.Now; stopTicks = DateTime.Now.Ticks; difference = stopwatch.ElapsedTicks; } catch (Exception e) { Console.WriteLine(Thread.CurrentThread.Name + ":" + e); timerException = e; } finally { Console.WriteLine("EndT3"); // TODO изменить вывод TimerInfo timer = new TimerInfo(Thread.CurrentThread.Name, start, startTicks, stop, stopTicks, difference, timerException); Logging(timer); } }
public AppContext() { canvas = Graphics.FromImage(iconBitmap); logFilePath = Path.Combine(Path.GetDirectoryName(Assembly.GetCallingAssembly().Location) ?? @"C:\WINDOWS\TEMP", "error.log"); notifyIcon = new NotifyIcon(); notifyIcon.Icon = Resources.ClevoECView; notifyIcon.ContextMenuStrip = new ContextMenuStrip(); notifyIcon.ContextMenuStrip.Items.Add(new ToolStripMenuItem("Set Fan 100%", null, MenuItemSet100_Click)); notifyIcon.ContextMenuStrip.Items.Add(new ToolStripMenuItem("Set Fan 90%", null, MenuItemSet90_Click)); notifyIcon.ContextMenuStrip.Items.Add(new ToolStripMenuItem("Set Fan 85%", null, MenuItemSet85_Click)); notifyIcon.ContextMenuStrip.Items.Add(new ToolStripMenuItem("Set Fan 80%", null, MenuItemSet80_Click)); notifyIcon.ContextMenuStrip.Items.Add(new ToolStripMenuItem("Set Fan 75%", null, MenuItemSet75_Click)); notifyIcon.ContextMenuStrip.Items.Add(new ToolStripMenuItem("Set Fan 70%", null, MenuItemSet70_Click)); notifyIcon.ContextMenuStrip.Items.Add(new ToolStripMenuItem("Set Fan 60%", null, MenuItemSet60_Click)); notifyIcon.ContextMenuStrip.Items.Add(new ToolStripMenuItem("Set Fan Auto", null, MenuItemSetAuto_Click)); notifyIcon.ContextMenuStrip.Items.Add(new ToolStripMenuItem("Exit", null, MenuItemExit_Click)); notifyIcon.Text = "ECView (initializing)"; notifyIcon.Visible = true; timerFan = new Timer(s => UpdateFanStateFromWmi(), null, 500, 500); timerUI = new System.Windows.Forms.Timer { Interval = 500, Enabled = true }; timerUI.Tick += TimerUI_Tick; timerUI.Start(); clevoWmiInstance = new ManagementObject("root\\WMI", "CLEVO_GET.InstanceName='ACPI\\PNP0C14\\0_0'", null); clevoWmiInstance.Get(); using (var searcher = new ManagementObjectSearcher(@"root\WMI", "SELECT * FROM MSAcpi_ThermalZoneTemperature")) { // ReSharper disable once PossibleInvalidCastExceptionInForeachLoop foreach (ManagementObject obj in searcher.Get()) { if (@"ACPI\ThermalZone\TZ0__0".Equals(obj["InstanceName"].ToString())) { msTz0WmiInstance = obj; break; } } } }
private void btnBaslat_Click(object sender, EventArgs e) { int calismaSuresi = int.Parse(seCalismaSuresi.Value.ToString()); int calismaAraligi = int.Parse(seCalismaAraligi.Value.ToString()); if (calismaSuresi == 0) { MessageBox.Show("Çalışma süresi 0 olamaz!", "HATA", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (calismaAraligi == 0) { MessageBox.Show("Çalışma aralığı 0 olamaz!", "HATA", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { kalanSure = calismaSuresi * 60; timer1 = new System.Windows.Forms.Timer(); timer1.Interval = calismaAraligi * 1000; timer1.Enabled = true; timer1.Start(); timer1.Tick += Timer1_Tick; } }
private void StressTestForm_Load(object sender, EventArgs e) { Watcher = new FileSystemWatcher(); // resize the window with configured values App.Configuration.WindowSettings.Load(this); StressTester = new StressTester(); StressTester.RequestProcessed += StressTester_RequestProcessed; StressTester.Progress += StressTester_Progress; if (string.IsNullOrEmpty(FileName) && !string.IsNullOrEmpty(App.Configuration.LastFileName)) { FileName = Path.GetFullPath(App.Configuration.LastFileName); if (!File.Exists(FileName)) FileName = null; } if (!string.IsNullOrEmpty(FileName)) OpenFile(FileName); else Requests = new List<HttpRequestData>(); LoadOptions(); OptionsPropertyGrid.SelectedObject = StressTester.Options; cmbListDisplayMode.SelectedItem = "Errors"; TabsResult.SelectedTab = tabOptions; AddRecentFiles(); if (!UnlockKey.IsRegistered()) { var t = new System.Windows.Forms.Timer(); t.Interval = 15*60*1000; // 15 mins t.Tick += t_Tick; t.Start(); } UpdateButtonStatus(); }
/// <summary> /// Action method when the calibrate button is clicked. /// </summary> public void calibrateButtonClicked() { // When the button is first pressed, show the sensorForm and start calabration. if (currentState == State.Calibrated) { // The method does not proceed as long as this messagebox is open. var result = MessageBox.Show("Weet u zeker dat u nog maal wilt kalibreren?", "Kalibratie", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2); if (result == DialogResult.Yes) { currentState = State.Uncalibrated; } } if (currentState == State.Uncalibrated) { // Show the form if (sensorController == null || sensorController.View.IsDisposed) { sensorController = new SensorViewController(fuzzyModel.hrSensor, fuzzyModel.gsrSensor); } sensorController.View.Show(); // Setup the countdown calibration timer timeSpanCounter = new TimeSpan(0, 10, 0); timer = new System.Windows.Forms.Timer(); timer.Tick += new EventHandler(timer_Tick); timer.Interval = 1000; // 1 second timer.Start(); calibrateButton.Text = timeSpanCounter.ToString(@"%h\:mm\:ss"); // Pass any manual input values for the first time, // they are passed on change. if (fuzzyModel.hrSensor.type == HRSensor.Type.ManualInput) { fuzzyModel.hrSensor.sensorValue = View.hrTrackBar.Value; } if (fuzzyModel.gsrSensor.type == GSRSensor.Type.ManualInput) { fuzzyModel.gsrSensor.sensorValue = View.gsrTrackBar.Value; } // Start calibrating fuzzyModel.startCalibration(); currentState = State.Calibrating; Console.WriteLine("Calibratie gestart"); } // When the button is pressed for a second time, the calibration is stopped else if (currentState == State.Calibrating) { // Stop the countdown and set the form back to the original state timer.Stop(); calibrateButton.Text = "Opnieuw kalibreren"; fuzzyModel.stopCalibration(); currentState = State.Calibrated; Console.WriteLine("Calibratie gestopt"); } }