MyException - 我的异常网
当前位置:我的异常网» C# » C#一直ping IP地址,出现界面卡死现象,求解决方案,

C#一直ping IP地址,出现界面卡死现象,求解决方案,该如何解决(3)

www.MyException.Cn  网友分享于:2013-02-20  浏览:33次

                int click_all = z - 1;
                MessageBox.Show(click_all.ToString());
                z = 0;
                click_all = 0;
            }
            else
            {                
                hexing_thread();
                Application.DeEvents();
            }

        }

        public void hexing_name_select()
        {
            hexing_line hexing = new hexing_line();

            for (int i = 0; i < hexing.hexing_name.Count(); i++)
            {
                hexing_date.Rows.Add();
                hexing_date.Rows[i].Cells[0].Value = hexing.hexing_name[i];
                hexing_date.Rows[i].Cells[1].Value = hexing.hexing_ip[i];
            }
            

        }
   public void hexing_thread()
        {
            int line_count = hexing_date.RowCount;//统计datagridview有多少行,就在下面设置多个线程
            Thread[] line_PING = new Thread[line_count];
            for (int a = 0; a < line_count; a++)
            {
                line_PING[a] = new Thread(new ParameterizedThreadStart(hexing_ping));
                line_PING[a].Start(a);
            }
        }

        public void hexing_ping(object obj)
        {

            int i = Convert.ToInt32(obj);
            Ping pp = new Ping();


            PingReply ppResult = pp.Send(Convert.ToString(hexing_date.Rows[i].Cells[1].Value), 10);

文章评论

软件开发程序错误异常ExceptionCopyright © 2009-2015 MyException 版权所有