private void button1_Click(object sender, EventArgs e)
{
for (int i = 1; i <= 255; i++)
{
new Thread(() =>
{
int ip = i;
try
{
Ping ping = new Ping();
int timeout = 10;
PingReply reply = ping.Send(IPAddress.Parse("192.168.0." + ip.ToString()), timeout);
if (reply.Status == IPStatus.Success)
{
Console.WriteLine("Succeess");
ListViewItem temp = new ListViewItem("192.168.0." + ip.ToString() + "Succeess");
listView1.Items.Add(temp);
}
else
{
Console.WriteLine("Fail");
ListViewItem temp = new ListViewItem("192.168.0." + ip.ToString() + "Fail");
listView1.Items.Add(temp);
}
}
catch
{
}
finally
{
}
}).Start();
}
}
버튼 생성
listview 생성
핑테스트가 완료되면 listview에 추가됨
'Programming > C#' 카테고리의 다른 글
| c# ListView 추가한 아이템 포커스 (0) | 2020.01.29 |
|---|---|
| c# 크로스 스레드 (0) | 2020.01.29 |
| monodevelop Mysql (0) | 2020.01.29 |
| C# ListView 선택된 아이템 가져오기 (0) | 2020.01.29 |
| c# Mysql (0) | 2020.01.29 |