public HEXWindow(MainWindow mw,socket socket) { InitializeComponent(); this.mw = mw; this.socket = socket; uiAnimation.translation(this, warningLine0); uiAnimation.translation(this, warningLine1); }
void testThreadpool(Object str) { String ip = str as String; string strScanIPAdd = ip; System.Net.IPAddress myScanIP = System.Net.IPAddress.Parse(strScanIPAdd);//转换成IP地址 //canditatedIP.Add(myScanIP);//record ip try { System.Net.IPHostEntry myScanHost = System.Net.Dns.GetHostEntry(myScanIP);//址获取 DNS 主机信息。 string strHostName = myScanHost.HostName.ToString();//获取主机的名 System.Threading.Thread t = new System.Threading.Thread(delegate() { //mw.debugBox.Dispatcher.Invoke(new Action(delegate() { mw.debugBox.AppendText(strScanIPAdd + "->" + strHostName + "\r\n"); })); mw.dw.debugBox.Dispatcher.Invoke(new Action(delegate() { mw.dw.debugBox.AppendText(strScanIPAdd + "->" + strHostName + "\r\n"); })); UpdatelistDelegate uplist = new UpdatelistDelegate((string _ip,string machine) => { canditatedIP.Remove(System.Net.IPAddress.Parse(_ip)); socket soc = new socket(mw,_ip); //soc.socket_received_Event += new socket.socket_Event_Handler(mw.received); mw.personalInfoList.Add(new slaveList(_ip, machine, "NULL", "NULL"));//list mw.socketCollection.Add(soc);//socket }); mw.iplistView.Dispatcher.Invoke(uplist, strScanIPAdd, strHostName); }); t.Start(); } catch (Exception error) { //System.Windows.MessageBox.Show(error.Message); } }
public void reScan() { System.Threading.Thread ttt = new System.Threading.Thread(delegate() { while(true) { System.Threading.Thread.Sleep(5000); foreach (System.Net.IPAddress address in canditatedIP) { try { System.Net.IPHostEntry myScanHost = System.Net.Dns.GetHostEntry(address);//址获取 DNS 主机信息。 string strHostName = myScanHost.HostName.ToString();//获取主机的名 System.Threading.Thread t = new System.Threading.Thread(delegate() { //mw.debugBox.Dispatcher.Invoke(new Action(delegate() { mw.debugBox.AppendText(address.AddressFamily.ToString() + "->" + strHostName + "\r\n"); })); mw.dw.debugBox.Dispatcher.Invoke(new Action(delegate() { mw.dw.debugBox.AppendText(address.AddressFamily.ToString() + "->" + strHostName + "\r\n"); })); UpdatelistDelegate uplist = new UpdatelistDelegate((string _ip, string machine) => { canditatedIP.Remove(System.Net.IPAddress.Parse(_ip)); socket soc = new socket(mw,_ip); //soc.socket_received_Event += new socket.socket_Event_Handler(mw.received); mw.personalInfoList.Add(new slaveList(_ip, machine, "NULL", "NULL"));//list mw.socketCollection.Add(soc);//socket }); mw.iplistView.Dispatcher.Invoke(uplist, address.AddressFamily.ToString(), strHostName); }); t.Start(); } catch (Exception error) { //System.Windows.MessageBox.Show(error.Message); } } } }); ttt.IsBackground = true; ttt.Start(); }