Guest User

Untitled

a guest
Dec 12th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. public void PingServer(string ip)
  2. {
  3. int timeout = 2000;
  4. Ping ping = new Ping();
  5. PingOptions options = new PingOptions();
  6. AutoResetEvent waiter = new AutoResetEvent(false);
  7. string data = "AAA";
  8. byte[] dataBuffer = Encoding.ASCII.GetBytes(data);
  9.  
  10. options.DontFragment = true;
  11. options.Ttl = 32;
  12.  
  13. ping.PingCompleted += (sender, eventArgs) =>
  14. {
  15. this.Invoke((MethodInvoker)delegate
  16. {
  17. setDelegate(eventArgs.UserInfo.Status(ip).ToString());
  18. });
  19. };
  20.  
  21. ping.SendAsync(ip, timeout, dataBuffer, options, waiter);
  22. //waiter.WaitOne();
  23. }
Add Comment
Please, Sign In to add comment