private void listView1_DoubleClick(object sender, EventArgs e) { if (listView1.SelectedItems != null) { Form2 frm; if (!(CheckOpened(listView1.SelectedItems[0].Text))) { try { string selected_ip = listView1.SelectedItems[0].SubItems[1].Text; frm = new Form2(listView1.SelectedItems[0].Text); form_entry f1 = new form_entry(); f1.form_refrence = frm; form_hash_table.Add(listView1.SelectedItems[0].Text, f1); new Thread(() => Application.Run(frm)).Start(); string selected_name = listView1.SelectedItems[0].Text; //Thread t2 = new Thread(new ThreadStart(() => request(selected_ip, selected_name))); //t2.Start(); } catch (Exception p) { //MessageBox.Show(p.Message); } } } //MessageBox.Show(listView1.SelectedItems[0].Text); }
public void read_stream(StreamReader sr, string name, string ip) { try { Thread t = null; Form2 f2; int c = 1; int c1 = 0; string read_txt = null; while (true) { c1++; string inp_msg = null; if ((live_list.ContainsKey(ip))) { // MessageBox.Show("killed1"); inp_msg = sr.ReadLine(); } else sr.Close(); if (inp_msg == null || inp_msg == "\r\n" || inp_msg == "\n" || inp_msg == "") { // MessageBox.Show("readthreadabort"); live_list.Remove(ip); listView1.Items.Clear(); refresh(); sr.Close(); return; } if (!(CheckOpened(name))) { f2 = new Form2(name); form_entry m1 = new form_entry(); m1.form_refrence = f2; form_hash_table.Add(name, m1); t = new Thread(() => Application.Run(f2)); t.Start(); Thread.Sleep(60); } else f2 = returnOpened(name); if (CheckOpened(name)) { f2 = returnOpened(name); f2.set_text(name + ":" + inp_msg); } if (!(live_list.ContainsKey(ip))) { //MessageBox.Show("killed2"); return; } Thread.Sleep(100); } } catch (Exception e) { if (e.GetType().ToString() == "System.IO.IOException") { live_list.Remove(ip); listView1.Items.Clear(); refresh(); sr.Close(); return; } if (e.GetType().ToString() == "System.Threading.ThreadAbortException") { //MessageBox.Show("readthreadabort"); live_list.Remove(ip); //listView1.Items.Clear(); refresh(); sr.Close(); return; } } }