private void threadCheckPort() { for (int i = 0; i < this.microPortList.Count; i++) { Dictionary <string, string> currPort = this.microPortList[i]; this.lblStatusMsg.Invoke(new MethodInvoker(delegate { this.listviewMicro.Items[i].SubItems[2].Text = "Checking..."; })); NetworkHelper.currentFakeIP = NetworkHelper.getMicroIp(currPort["host"], Convert.ToInt32(currPort["port"])); if (NetworkHelper.currentFakeIP != "") { this.lblStatusMsg.Invoke(new MethodInvoker(delegate { this.listviewMicro.Items[i].SubItems[2].Text = "OK"; })); } else { this.lblStatusMsg.Invoke(new MethodInvoker(delegate { this.listviewMicro.Items[i].SubItems[2].Text = "Die"; })); } } this.lblStatusMsg.Invoke(new MethodInvoker(delegate { this.btnMicroCheck.Enabled = true; })); }
public bool microFakeIp() { //get current micro index bool result = false; int index = -1; int nextIndex = 0; string currProxyHost = this.ipProxyHost.Text; string currProxyPort = this.numProxyPort.Value.ToString(); for (int i = 0; i < this.microPortList.Count; i++) { if (this.microPortList[i]["host"] == currProxyHost && this.microPortList[i]["port"] == currProxyPort) { index = i; break; } } do { nextIndex = index + 1; if (nextIndex >= this.microPortList.Count) { Thread.Sleep(1000); nextIndex = 0; } string nextHost = this.microPortList[nextIndex]["host"]; int nextPort = Convert.ToInt32(this.microPortList[nextIndex]["port"]); string oldIp = this.microPortList[nextIndex]["ip"]; this.Invoke(new MethodInvoker(delegate { this.ipProxyHost.Text = nextHost; this.numProxyPort.Value = nextPort; })); this.updateProcessLog("Checking micro sock..."); NetworkHelper.currentFakeIP = NetworkHelper.getMicroIp(nextHost, nextPort); if (NetworkHelper.currentFakeIP != "") { if (NetworkHelper.currentFakeIP != oldIp) { this.microPortList[nextIndex]["ip"] = NetworkHelper.currentFakeIP; if (this.deviceComm.isConnect()) { this.setProxy(); } this.button23.Invoke(new MethodInvoker(delegate { this.button23.Text = "Disable Proxy"; this.button23.BackColor = Color.Red; })); result = true; break; } else { this.updateProcessLog("Micro ip not refresh: " + oldIp); Thread.Sleep(1000); } } else { this.updateProcessLog("Micro sock died"); Thread.Sleep(1000); } }while (true); return(result); }