1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
| public void BT_SCAN_Click(object sender, EventArgs e)
{
Thread th = new Thread(new ParameterizedThreadStart(pingue));
Thread th2 = new Thread(new ParameterizedThreadStart(pingue));
Thread th3 = new Thread(new ParameterizedThreadStart(pingue));
int j = 100, k = 200; ;
for (int i = 1; i < 100; i++)
{
th.Start(i);
th2.Start(j);
th3.Start(k);
th.Join();
th2.Join();
th3.Join();
j++;
k++;
}
}
public void pingue(object tst)
{
Ping pingSender = new Ping();
PingOptions options = new PingOptions();
String data = new String('a', 8);
byte[] buffer = Encoding.ASCII.GetBytes(data);
int timeout = 120;
IPHostEntry entry = Dns.GetHostEntry("192.168.1."+(tst.ToString()));
PingReply reply = pingSender.Send(entry.AddressList[0], timeout, buffer, options);
LIB_SCAN2.Items.Add("192.168.1."+(tst.toString())).SubItems.Add(reply.RoundtripTime.ToString() + " ms");
} |
Partager