//All logic pertaining to starting the service private void startLogic() { Scrap_wrapper.ResetState(); if (!serviceRunning) { button_start.Enabled = false; button_stop.Enabled = true; button_settings.Enabled = false; Scrap_wrapper.UpdateImage(); timer1.Interval = Cfg.interval * 1000 * 60; timer1.Start(); Wallpaper.SetDefaultStyle(); if (Cfg.setwallpaper) { Wallpaper.Set(Cfg.image_folder + "\\wallpaper.bmp"); } serviceRunning = true; runningLabel.Text = " Running"; runningLabel.ForeColor = Color.DarkGreen; } else { MessageBox.Show("Service already running"); } contextMenuSetter(); }
private void timer1_Tick(object sender, EventArgs e) { System.Threading.Thread.Sleep(10000); // wait 10 secs for Internet reconnection after system resume. Scrap_wrapper.UpdateImage(); if (Cfg.setwallpaper) { Wallpaper.Set(Cfg.image_folder + "\\wallpaper.bmp"); } }
//All logic pertaining to starting the service private async Task StartLogic(CancellationTokenSource _cancelSource) { await Scrap_wrapper.UpdateImage(_cancelSource); Wallpaper.SetDefaultStyle(); if (Cfg.setwallpaper) { Wallpaper.Set(Cfg.image_folder + "\\wallpaper.bmp"); } }
private async void timer1_Tick(object sender, EventArgs e) { _cancelSource = new CancellationTokenSource(); await Task.Delay(TimeSpan.FromSeconds(10)); // wait 10 secs for Internet reconnection after system resume. await Scrap_wrapper.UpdateImage(_cancelSource); if (Cfg.setwallpaper) { Wallpaper.Set(Cfg.image_folder + "\\wallpaper.bmp"); } }
private void timer1_Tick(object sender, EventArgs e) { if (Interlocked.Exchange(ref inTimer1, 1) == 0) { if (timer1.Interval != Cfg.interval * 1000 * 60) { timer1.Interval = Cfg.interval * 1000 * 60; // set the interval } System.Threading.Thread.Sleep(5000); // wait 5 secs for Internet reconnection after system resume. Scrap_wrapper.UpdateImage(); if (Cfg.setwallpaper) { Wallpaper.Set(Cfg.image_folder + "\\wallpaper.bmp"); } Interlocked.Exchange(ref inTimer1, 0); } }