Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public bool connect(string ip, int port)
- {
- TcpClient tcpClient = new TcpClient();
- try
- {
- tcpClient.Connect(ip, port);
- return true;
- }
- catch
- {
- return false;
- }
- finally
- {
- tcpClient.Close();
- }
- }
- private void Form1_Shown(object sender, EventArgs e)
- {
- List<string> listPath1 = new List<string>();
- List<string> listPath2 = new List<string>();
- GetAllPaths(treeView1.Nodes[0].Nodes[0], listPath1);
- GetAllPaths(treeView1.Nodes[0].Nodes[1], listPath2);
- listPath1.RemoveAt(0);
- listPath2.RemoveAt(0);
- string[] tmp1 = listPath1.ToArray();
- string[] tmp2 = listPath2.ToArray();
- List<Thread> ThrArr = new List<Thread>();
- string[] tmp;
- for (int i = 0; i < tmp1.Length; i++) {
- tmp = tmp1[i].Split(' ');
- int temp = i;
- Thread devthread = new Thread(() => connect(tmp[1], Convert.ToInt32(tmp[4])));
- devthread.Name = "thr" + i.ToString();
- ThrArr.Add(devthread);
- //devthread.Start();
- //Thread.Sleep(10);
- }
- foreach (Thread thread in ThrArr)
- {
- thread.Start();
- treeView1.Nodes.Add("Potok" + thread.Name);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement