Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void PingServer(string ip)
- {
- int timeout = 2000;
- Ping ping = new Ping();
- PingOptions options = new PingOptions();
- AutoResetEvent waiter = new AutoResetEvent(false);
- string data = "AAA";
- byte[] dataBuffer = Encoding.ASCII.GetBytes(data);
- options.DontFragment = true;
- options.Ttl = 32;
- ping.PingCompleted += (sender, eventArgs) =>
- {
- this.Invoke((MethodInvoker)delegate
- {
- setDelegate(eventArgs.UserInfo.Status(ip).ToString());
- });
- };
- ping.SendAsync(ip, timeout, dataBuffer, options, waiter);
- //waiter.WaitOne();
- }
Add Comment
Please, Sign In to add comment