private void btnStart_Click(object sender, EventArgs e) { try { if (timer != null) { timer.Stop(); timer = null; } count_total = int.Parse(tbCount.Text); if (count_total > 0) { tsslStatus.Text = "Creating PPPoE Config ..."; System.Threading.Thread.Sleep(1000); ppoe = new RasDialManger(tbEntryName.Text.Trim(), tbUsername.Text.Trim(), tbPassword.Text.Trim()); timer = new Timer(); timer.Interval = int.Parse(tbInterval.Text); timer.Tick += Timer_Tick; timer.Start(); } } catch (Exception exp) { Console.WriteLine(exp.ToString()); } }
private void ChangeIP(int max_retry_count = 10) { try { string new_ip = string.Empty; int counter = 0; if (string.IsNullOrEmpty(last_ip)) { last_ip = RasDialManger.GetPublicIP(); } do { tsslStatus.Text = "Disconnecting..."; ppoe.Disconnection(); tsslStatus.Text = "Waiting for 5 second ..."; System.Threading.Thread.Sleep(5000); tsslStatus.Text = "Connecting..."; ppoe.Connection(); new_ip = RasDialManger.GetPublicIP(); tssl_ip.Text = new_ip; Console.WriteLine("new ip:" + new_ip); Console.WriteLine("last ip:" + last_ip); counter++; if (counter >= max_retry_count) { break; } } while (last_ip.Equals(new_ip)); last_ip = new_ip; } catch (Exception exp) { Console.WriteLine(exp.ToString()); } }