public FormMain() { InitializeComponent(); TGram.Initialize(); detector.OnChangeDetected += OnChangeDetected; //detector.Start(); }
private async void Button1_Click(object sender, EventArgs e) { label1.ForeColor = Color.Black; label1.Text = "starting in 10s"; await Task.Delay(10000); label1.Text = "monitoring..."; detector.Start(); var text = string.Format("[{0} {1}]: started monitoring.", DateTime.Now.ToShortDateString(), DateTime.Now.ToLongTimeString()); TGram.SendMessage(text); }
public void OnChangeDetected() { string notification = string.Format("[{0} {1}]: change detected.", DateTime.Now.ToShortDateString(), DateTime.Now.ToLongTimeString()); Console.WriteLine(notification + " Sending Telegram Notification"); label1.Invoke(new Action(() => { label1.Text = notification; label1.ForeColor = Color.Red; })); TGram.SendMessage(notification); detector.Stop(); }