private async void button1_Click(object sender, EventArgs e) { //timer to extend waiting and system setup : this.WelcomeTimer.Start(); this.timer2.Start(); this.WelcomeProgressBar.Visible = true; //Log current operation: s3log.logOperation(sender); //"await" needs the async in the function declaration and equals "Sleep" await Task.Delay(2000); //MetroFramework.MetroMessageBox.Show(this, (Pinger("stackoverflow.com", 4)).ToString()); if (Pinger("stackoverflow.com", 5) > 129) { MetroFramework.MetroMessageBox.Show(this, "the connection is lost"); // this = current form this.WelcomeProgressBar.Value = 0; WelcomeTimer.Stop(); this.timer2.Stop(); } else { //start the next form Form ATM3 = new ATM3(); // Instantiate a Form object. ATM3.Show(); //show the new Form WelcomeTimer.Stop(); //hide the old form this.Visible = false; //Hide the old form } }
private void metroButton2_Click(object sender, EventArgs e) { //continue to next form Form ATM3 = new ATM3(); // Instantiate a Form object. ATM3.Show(); //show the new Form //Log current operation: s3log.logOperation(sender); this.Visible = false; }