.NET Framework Bookmark and Share   
 index > Network Class Library (System.Net) > Ping in Thread (C#)
 

Ping in Thread (C#)

How can I make a ping to a website or IP address in thread and all in run-time?


Jassim Rahma
Jassim Rahma

private void button1_Click(object sender, EventArgs e)

{

//for synchronous ping

System.Net.NetworkInformation.Ping p = new System.Net.NetworkInformation.Ping ();

System.Net.NetworkInformation.PingReply rep= p.Send("www.yahoo.com" , 2000);

Console .WriteLine(rep.Status);


//for asyncdhronous ping

p.SendAsync("www.yahoo.com" ,null );//you can use IP address as well

p.PingCompleted += new System.Net.NetworkInformation.PingCompletedEventHandler (p_PingCompleted);

}

void p_PingCompleted(object sender, System.Net.NetworkInformation.PingCompletedEventArgs e)

{

Console .Write(e.Reply.Status);

}


Jahedur.Rahman

private void button1_Click(object sender, EventArgs e)

{

//for synchronous ping

System.Net.NetworkInformation.Ping p = new System.Net.NetworkInformation.Ping ();

System.Net.NetworkInformation.PingReply rep= p.Send("www.yahoo.com" , 2000);

Console .WriteLine(rep.Status);


//for asyncdhronous ping

p.SendAsync("www.yahoo.com" ,null );//you can use IP address as well

p.PingCompleted += new System.Net.NetworkInformation.PingCompletedEventHandler (p_PingCompleted);

}

void p_PingCompleted(object sender, System.Net.NetworkInformation.PingCompletedEventArgs e)

{

Console .Write(e.Reply.Status);

}


Jahedur.Rahman

You can use google to search for other answers

Custom Search

More Threads

• How to download a webpage in binary file format?
• why msg too long time to process
• Problems with NTLM proxy authentication and HTTPS
• how to show upload progress in steps
• The information returned from the local end point and netstat –an don’t match.
• downloading all files in directory http and c#
• send http-form with data, work on requested side
• HttpWebRequest Basic Authentication fails in C# windows program.
• Originate mail from an external dll
• TcpClient: what happens when server thread killed by another process?