private void pbEdit_Click(object sender, EventArgs e) { //修改指定连接 getVpnName(); ThreadStart starter = delegate { VPNTools.editConnection(currentVPN); }; Thread thread = new Thread(starter); thread.IsBackground = true; thread.Start(); }
private void pbDisConnect_Click(object sender, EventArgs e) { //断开连接 checkConntect(); getVpnName(); //使用后台线程执行 ThreadStart starter = delegate { VPNTools.disConnect(currentVPN); }; Thread thread = new Thread(starter); thread.IsBackground = true; thread.Start(); checkConntect(); }
private void pbConnect_Click(object sender, EventArgs e) { //连接默认VPN getVpnName(); checkConntect(); if (currentVPN != null) { //使用后台线程执行 ThreadStart starter = delegate { VPNTools.connect(currentVPN, user[0], user[1]); }; Thread thread = new Thread(starter); thread.IsBackground = true; thread.Start(); } }
private void checkConntect() { //检测VPN是否连接 String result = VPNTools.checkCoonnect(); if (result.Equals("false")) { pbLine.Image = Resources.disconnect_line; } else { pbLine.Image = Resources.connect_line; currentVPN = result; foreach (Control control in gbVPN.Controls) { if (((RadioButton)control).Text.Equals(currentVPN)) { ((RadioButton)control).Checked = true; } } } }