Inheritance: System.ComponentModel.AsyncCompletedEventArgs
Ejemplo n.º 1
0
 static void pingDone(object sender, PingCompletedEventArgs e)
 {
     string ip = (string)e.UserState;
     if (e.Reply != null && e.Reply.Status == IPStatus.Success)
     {
         if (resolveNames)
         {
             string name = null;
             try
             {
                 IPHostEntry hostEntry = Dns.GetHostEntry(ip);
                 name = hostEntry.HostName;
             }
             catch (SocketException ex)
             {
                 name = "?";
             }
             Functions.log(string.Format("{0} ({1}) is up: ({2} ms)", ip, name, e.Reply.RoundtripTime), 2);
         }
         else
         { //but it's reachable doe.
             Functions.log(string.Format("{0} is up: ({1} ms)", ip, e.Reply.RoundtripTime), 2);
         }
         lock(lockObj)
         {
             upCount++;
         }
     }
     else if (e.Reply == null)
     {
         Functions.log(string.Format("Pinging {0} failed. (Null Reply object?)", ip), 3);
     }
     countdown.Signal();
 }
Ejemplo n.º 2
0
        private async void InternalSendAsync(IPAddress address, byte[] buffer, int timeout, PingOptions options)
        {
            AsyncOperation asyncOp = _asyncOp;
            SendOrPostCallback callback = _onPingCompletedDelegate;

            PingReply pr = null;
            Exception pingException = null;

            try
            {
                if (RawSocketPermissions.CanUseRawSockets())
                {
                    pr = await SendIcmpEchoRequestOverRawSocket(address, buffer, timeout, options).ConfigureAwait(false);
                }
                else
                {
                    pr = await SendWithPingUtility(address, buffer, timeout, options).ConfigureAwait(false);
                }
            }
            catch (Exception e)
            {
                pingException = e;
            }

            // At this point, either PR has a real PingReply in it, or pingException has an Exception in it.
            var ea = new PingCompletedEventArgs(
                pr,
                pingException,
                false,
                asyncOp.UserSuppliedState);

            Finish();
            asyncOp.PostOperationCompleted(callback, ea);
        }
Ejemplo n.º 3
0
        private void PingCompletedCallback(object sender, PingCompletedEventArgs e)
        {
            // If the operation was canceled, display a message to the user.
            if (e.Cancelled)
            {
                isPing = false;
                //Console.WriteLine("Ping canceled.");
                // Let the main thread resume. 
                // UserToken is the AutoResetEvent object that the main thread 
                // is waiting for.
                ((AutoResetEvent)e.UserState).Set();
            }

            // If an error occurred, display the exception to the user.
            if (e.Error != null)
            {
                isPing = false;
                //Console.WriteLine("Ping failed:");
                //Console.WriteLine(e.Error.ToString());

                // Let the main thread resume. 
                ((AutoResetEvent)e.UserState).Set();
            }

            PingReply reply = e.Reply;

            DisplayReply(reply);

            // Let the main thread resume.
            //((AutoResetEvent)e.UserState).Set();
        }
Ejemplo n.º 4
0
        public void PingCompleate(object sender, PingCompletedEventArgs e)
        {
            Log_Verb("Ping Complete");
            PingData seq = (PingData)e.UserState;
            PingReply rep = e.Reply;
            Ping ping = (Ping)sender;

            lock (sentry)
            {
                pings.Remove(ping);
                ping.Dispose();

                switch (rep.Status)
                {
                    case IPStatus.Success:
                        ICMP retICMP = new ICMP(seq.Data);
                        retICMP.HeaderData = seq.HeaderData;
                        retICMP.Type = 0; //echo reply
                        recvBuff.Add(retICMP);
                        break;
                    default:
                        //ping failed
                        open -= 1;
                        if (open == 0)
                        {
                            RaiseEventConnectionClosed();
                        }
                        break;
                }
            }
        }
Ejemplo n.º 5
0
        private void Ping_PingCompleted(object sender, System.Net.NetworkInformation.PingCompletedEventArgs e)
        {
            // Get Latency
            if (e.Error != null)
            {
                Logger.Instance.LogMessage(TracingLevel.ERROR, $"Ping error for host {settings.ServerName} {e.Error}");
                return;
            }

            if (e.Cancelled)
            {
                pingCanceled = true;
                return;
            }

            if (e.Reply == null)
            {
                Logger.Instance.LogMessage(TracingLevel.ERROR, $"Ping reply is null for host {settings.ServerName}");
                return;
            }

            if (e.Reply.Status == IPStatus.TimedOut || e.Reply.Status == IPStatus.DestinationHostUnreachable || e.Reply.Status == IPStatus.DestinationNetworkUnreachable)
            {
                pingCanceled = true;
                return;
            }

            pingCanceled = false;
            pingLatency  = e.Reply.RoundtripTime;
        }
Ejemplo n.º 6
0
 protected void OnPingCompleted(PingCompletedEventArgs e)
 {
     PingCompletedEventHandler handler = PingCompleted;
     if (handler != null)
     {
         handler(this, e);
     }
 }
Ejemplo n.º 7
0
 private void pingcom(object sender, PingCompletedEventArgs e)
 {
     PingReply myrep = e.Reply;
     if (myrep.Status == IPStatus.Success)
     {
         textBox1.Text += e.Reply.Address + "  time:" + myrep.RoundtripTime + "ms\r\n";
     }
     ((AutoResetEvent)e.UserState).Set();
 }
Ejemplo n.º 8
0
        private static void PingCompleted(object sender, PingCompletedEventArgs e)
        {
            if (e.Reply != null && e.Reply.Status == IPStatus.Success) {
                Thread SearchServer = new Thread(() => CheckServer(e));
                SearchServer.SetApartmentState(ApartmentState.STA);
                SearchServer.Name = "SearchServer";

                SearchServer.Start();
            }
        }
Ejemplo n.º 9
0
 private void LastPingCompleted(object sender, PingCompletedEventArgs e)
 {
     string ip = (string)e.UserState;
     if (e.Reply != null && e.Reply.Status == IPStatus.Success)
     {
         iplist.Add(ip);
     }
     if (PingListCompleted != null)
         PingListCompleted(iplist);
 }
Ejemplo n.º 10
0
 private void pPing_PingCompleted(object sender, PingCompletedEventArgs e)
 {
     if (e.Error == null)
         DI.log.info("Ping status: {0}", e.Reply.Status.ToString());
     else
         DI.log.error("in Ping: {0}", e.Error.Message);
     if (ePingCompleted != null)
         foreach (Delegate dDelegate in ePingCompleted.GetInvocationList())
             dDelegate.DynamicInvoke(new[] {sender, e});
 }
Ejemplo n.º 11
0
 private void PingCompleted(object sender, PingCompletedEventArgs e)
 {
     if (e.Error != null) {
         WriteError(e.Error, (string) e.UserState);
     } else if (e.Cancelled) {
         Console.WriteLine("{0}, Cancelled", e.UserState);
     } else {
         WriteStatus(e.Reply, (string) e.UserState);
     }
 }
Ejemplo n.º 12
0
 private static void CheckServer(PingCompletedEventArgs e)
 {
     TcpClient connection = new TcpClient();
     try {
         connection.Connect("" + e.UserState, port);
         if (connection.Connected) {
             LoginUC.GetInstance().AddServerIp("" + e.UserState);
         }
     } catch (Exception) { }
 }
Ejemplo n.º 13
0
        private void _myPing_PingCompleted(object sender, PingCompletedEventArgs e)
        {

            if (e.Reply.Status == IPStatus.Success)
            {
                
                pingstr += (e.Reply.Address.ToString() + "  |") + '\n';
              
            }

        }
Ejemplo n.º 14
0
        void ping_PingCompleted(object sender, PingCompletedEventArgs e)
        {
            if (e.Reply == null)
                return;

            PingReply reply = e.Reply;
            if (reply.Status == IPStatus.Success)
            {
                this.Status.Latency = (int)reply.RoundtripTime;
                ((Action)e.UserState).Invoke();
            }
        }
Ejemplo n.º 15
0
 private static void p_pingCompleted(object sender, System.Net.NetworkInformation.PingCompletedEventArgs e)
 {
     if (e.Reply.Status == IPStatus.Success)
     {
         try
         {
             Console.WriteLine($"[{(e.Reply.RoundtripTime == 0 ? "LOCAL" : e.Reply.RoundtripTime.ToString()).PadRight(5, '·')}] {e.UserState.ToString().PadRight(15)}{Dns.GetHostEntry(e.UserState.ToString()).HostName}");
         }
         catch
         {
             Console.WriteLine($"[{(e.Reply.RoundtripTime == 0 ? "LOCAL" : e.Reply.RoundtripTime.ToString()).PadRight(5, '·')}] {e.UserState.ToString().PadRight(15)}");
         }
     }
 }
Ejemplo n.º 16
0
 private static void PingSender_PingCompleted(object sender, PingCompletedEventArgs e)
 {
     if (e.Reply.Status > 0)
     {
         Log(e.Reply.Status.ToString());
     }
     else
     {
         string host = e.Reply.Address.ToString();
         int size = e.Reply.Buffer.Length;
         long time = e.Reply.RoundtripTime;
         int ttl = e.Reply.Options.Ttl;
         Log("Réponse de " + host + " : octets=" + size + " temps=" + time + "ms TTL=" + ttl);
     }
     pingCount++;
 }
Ejemplo n.º 17
0
        private void InternalSendAsync(IPAddress address, byte[] buffer, int timeout, PingOptions options)
        {
            AsyncOperation asyncOp = _asyncOp;
            SendOrPostCallback callback = _onPingCompletedDelegate;

            // TODO: Implement this (#2487)

            PingException pe = new PingException(SR.net_ping, new PlatformNotSupportedException());
            var ea = new PingCompletedEventArgs(
                new PingReply(address, default(PingOptions), default(IPStatus), default(long), buffer), 
                pe, 
                false, 
                asyncOp.UserSuppliedState);

            Finish();
            asyncOp.PostOperationCompleted(callback, ea);
        }
Ejemplo n.º 18
0
 void Ping_PingCompleted(object sender, PingCompletedEventArgs e)
 {
     if (e.Cancelled == true)
     {
         try
         {
             OnMultiPingCompleted(new MultiPingCompletedEventArgs(CreateReply(e.Reply.Address, m_Replys.ToArray()), e.Error, e.Cancelled, e.UserState));
         }
         catch { }
         finally
         {
             m_Pinging = false;
         }
         return;
     }
     else
     {
         m_Replys.Add(e.Reply);
         m_Times--;
         try
         {
             OnSinglePingCompleted(e);
         }
         catch { }
         if (m_Times <= 0)
         {
             try
             {
                 OnMultiPingCompleted(new MultiPingCompletedEventArgs(CreateReply(e.Reply.Address, m_Replys.ToArray()), e.Error, e.Cancelled, e.UserState));
             }
             catch { }
             finally
             {
                 m_Pinging = false;
             }
             return;
         }
         else
         {
             Threading.Thread.Sleep(m_Interval);
             m_Ping.SendAsync(e.Reply.Address, e.UserState);
         }
     }
 }
Ejemplo n.º 19
0
 private void _Pin_PingCompleted(object sender, PingCompletedEventArgs e)
 {
     if(e.Error != null)
     {
         _ReplyStat = e.Error.Message;
     }else if(e.Cancelled )
     {
         _ReplyStat = "User Canceled";
     }else { 
     
     _ReplyStat = e.Reply.Status == IPStatus.Success ? "OK" : "NG";
     }
     
     _Completed = true;
     //Console.WriteLine("{0}: {1}",_IPaddress,this.ReplyStat);
     _ShowResuletAction(_IPaddress.ToString(), this.ReplyStat);
     this.PinResetEvent.Set();
     
 }
Ejemplo n.º 20
0
        public static void PingCompletedCallback(object sender, PingCompletedEventArgs e)
        {
            if (e.Cancelled)
            {
                Log("Ping canceled.");
                return;
            }

            
            if (e.Error != null)
            {
                Log("Ping failed:");
                Log(e.Error.ToString());
                return;
            }
            
            PingReply reply = e.Reply;

            DisplayReply(reply,e.UserState.ToString());
        }
Ejemplo n.º 21
0
        private void ContinueAsyncSend(object state)
        {
            // FxCop: need to snapshot the address here, so we're sure that it's not changed between the permission
            // check and the operation, and to be sure that IPAddress.ToString() is called and not some override.
            Debug.Assert(_asyncOp != null, "Null AsyncOp?");

            AsyncStateObject stateObject = (AsyncStateObject)state;

            try
            {
                IPAddress addressSnapshot = Dns.GetHostAddressesAsync(stateObject.HostName).GetAwaiter().GetResult()[0];
                InternalSend(addressSnapshot, stateObject.Buffer, stateObject.Timeout, stateObject.Options, true);
            }
            catch (Exception e)
            {
                PingException          pe        = new PingException(SR.net_ping, e);
                PingCompletedEventArgs eventArgs = new PingCompletedEventArgs(null, pe, false, _asyncOp.UserSuppliedState);
                Finish(true);
                _asyncOp.PostOperationCompleted(_onPingCompletedDelegate, eventArgs);
            }
        }
Ejemplo n.º 22
0
 /**
  * function to act as event listner to the pings sent to 
  * different systems retrieved by thr ARP -g command
  */
 public static void p_PingCompleted(object sender, PingCompletedEventArgs e)
 {
     string ip = (string)e.UserState;
     if (e.Reply != null && e.Reply.Status == IPStatus.Success)
     {
         string name;
         try
         {
             IPHostEntry hostEntry = Dns.GetHostEntry(ip);
             try
             {
                 /**
                  * considering IP address is not needed
                  */
                 name = hostEntry.HostName;
                 File.AppendAllText(primaryFolder + @"\tmp\alluserlist.data", name + Environment.NewLine);
             }
             catch (SocketException ex) { }
         }
         catch (Exception ex) { }
     }
 }
Ejemplo n.º 23
0
        public void PingCompleate(object sender, System.Net.NetworkInformation.PingCompletedEventArgs e)
        {
            PingData  Seq = (PingData)e.UserState;
            PingReply rep = e.Reply;

            lock (sentry)
            {
                switch (rep.Status)
                {
                case IPStatus.Success:
                    ICMP retICMP = new ICMP(Seq.Data);
                    retICMP.HeaderData = Seq.HeaderData;
                    retICMP.Type       = 0; //echo reply
                    recvbuff.Add(retICMP);
                    break;

                default:
                    open -= 1;
                    break;
                }
            }
        }
Ejemplo n.º 24
0
 private void HandleCompletion(TaskCompletionSource <PingReply> tcs, PingCompletedEventArgs e, PingCompletedEventHandler handler)
 {
     if (e.UserState == tcs)
     {
         try { this.PingCompleted -= handler; }
         finally
         {
             if (e.Error != null)
             {
                 tcs.TrySetException(e.Error);
             }
             else if (e.Cancelled)
             {
                 tcs.TrySetCanceled();
             }
             else
             {
                 tcs.TrySetResult(e.Reply);
             }
         }
     }
 }
Ejemplo n.º 25
0
        static void p_PingCompleted(object sender, PingCompletedEventArgs e)
        {
            string ip = (string)e.UserState;
            if (e.Reply != null && e.Reply.Status == IPStatus.Success)
            {
                if (!Computers.comp.Contains(ip))
                {
                    Computers.comp.Add(ip);
                }
                /*if (resolveNames)
                {
                    string name;
                    try
                    {
                        IPHostEntry hostEntry = Dns.GetHostEntry(ip);
                        name = hostEntry.HostName;
                    }
                    catch (SocketException ex)
                    {
                        name = "?";
                    }
                    //Console.WriteLine("{0} ({1}) is up: ({2} ms)", ip, name, e.Reply.RoundtripTime);
                }
                else
                {
                    Console.WriteLine("{0} is up: ({1} ms)", ip, e.Reply.RoundtripTime);
                }*/
                lock (lockObj)
                {
                    upCount++;
                }
            }
            else if (e.Reply == null)
            {
             //   Console.WriteLine("Pinging {0} failed. (Null Reply object?)", ip);
            }

            countdown.Signal();
        }
Ejemplo n.º 26
0
 /// <summary>
 /// ping完成回掉函数
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void _myPing_PingCompleted(object sender, PingCompletedEventArgs e)
 {
     //ping通说明该主机可连接
     if (e.Reply.Status == IPStatus.Success)
     {
         ListViewItem tmp = new ListViewItem(e.Reply.Address.ToString());
         result.Add(tmp);
     }
 }
Ejemplo n.º 27
0
 // Adapted from
 // stackoverflow.com/questions/4042789/how-toget-ip-of-all-hosts-in-lan
 static void p_PingCompleted(object sender, PingCompletedEventArgs e)
 {
     string ip = (string)e.UserState;
     if (e.Reply != null && e.Reply.Status == IPStatus.Success)
     {
         lock (IPAddresses)
         {
             if (!IPAddresses.Contains(ip))
             {
                 IPAddresses.Add(ip);
             }
         }
     }
     countdown.Signal();
 }
Ejemplo n.º 28
0
Archivo: Ping.cs Proyecto: vargaz/mono
		protected void OnPingCompleted (PingCompletedEventArgs e)
		{
			user_async_state = null;
			worker = null;
#if NET_4_5
			cts = null;
#endif

			if (PingCompleted != null)
				PingCompleted (this, e);
		}
 protected void OnPingCompleted(PingCompletedEventArgs e)
 {
 }
Ejemplo n.º 30
0
 protected void OnPingCompleted(PingCompletedEventArgs e)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 31
0
        void Pingtest(object sender, PingCompletedEventArgs e)
        {
            PingReply reply = e.Reply;

              if (reply == null)

             {
                richTextBox1.SelectionColor = Color.Red;
                richTextBox1.AppendText("Update server is offline.\n");
                richTextBox1.SelectionColor = Color.White;
                button1.Enabled = false;

             }

            if (reply.Status == IPStatus.Success)

            {

                 richTextBox1.SelectionColor = Color.ForestGreen;
                 richTextBox1.AppendText("Update server is online.\n");
                 richTextBox1.SelectionColor = Color.White;
            }
        }
Ejemplo n.º 32
0
 private static void PingCompletedCallback(object sender, PingCompletedEventArgs e)
 {
     WaitingForReply = false;
     if (e.Reply != null && e.Reply.Status == IPStatus.Success)
     {
         LastRoundtripTime = e.Reply.RoundtripTime;
     }
     else { LastRoundtripTime = 0; }
 }
Ejemplo n.º 33
0
 private static void SinglePingCompleted(Object sender, PingCompletedEventArgs e)
 {
     Console.WriteLine(e.Reply.ToContentString());
 }
 private void ProcessPingResult(PingCompletedEventArgs e)
 {
     if (e.Reply.Status == IPStatus.Success)
     {
         currentState = DroneNetworkConnectionState.PingSuccesful;
         UpdateConnectionStatus();
     }
     else if (currentPingRetries < maxPingRetries)
     {
         TryToPingDrone();
     }
     else
     {
         AddFailureReasonForCurrentInterface("Pinging the drone was not succesful");
         ScanNextNetworkInterface();
     }
 }
Ejemplo n.º 35
0
        private void pingSender_PingCompleted(object sender, PingCompletedEventArgs e)
        {
            if (this.disposing)
                return;

            try
            {
                if (Thread.CurrentThread.Name == null)
                    Thread.CurrentThread.Name = "Ping Completed";

                ((AutoResetEvent) e.UserState).Set();

                if (e.Reply.Status == IPStatus.Success)
                {
                    lock (this.threadLocker)
                    {
                        PingReplyData pd = new PingReplyData(
                            this.counter++,
                            "Reply from: ",
                            this.hostName,
                            this.destination,
                            e.Reply.Buffer.Length,
                            e.Reply.Options.Ttl,
                            e.Reply.RoundtripTime,
                            DateTime.Now.ToLongTimeString());

                        lock (this.pingList)
                        {
                            this.pingList.Add(pd);
                        }

						if (!this.IsDisposed && !this.Disposing)
							this.InvokeIfNecessary(() => this.Invoke(this.DoUpdateForm));
                        this.pingReady = true;
                    }
                }
                else if (!e.Cancelled)
                {
                    String status = String.Empty;
                    switch (e.Reply.Status)
                    {
                        case IPStatus.TimedOut:
                            status = "Request timed out.";
                            break;

                        case IPStatus.DestinationHostUnreachable:
                            status = "Destination host unreachable.";
                            break;
                    }

                    lock (this.threadLocker)
                    {
                        this.pingSender.SendAsyncCancel();
                        PingReplyData pd = new PingReplyData(
                            this.counter++, status, String.Empty, String.Empty, 0, 0, 0, DateTime.Now.ToLongTimeString());

                        lock (this.pingList)
                        {
                            this.pingList.Add(pd);
                        }
                        
						if (!this.IsDisposed && !this.Disposing)
							this.InvokeIfNecessary(() => this.Invoke(this.DoUpdateForm));
                        this.pingReady = true;
                    }
                }
            }
            catch (Exception ex)
            {
                Log.Info("Error on Ping.PingCompleted", ex);
            }
            finally
            {
                ((AutoResetEvent) e.UserState).Set();
            }
        }
 private void pingSender_PingCompleted(object sender, PingCompletedEventArgs e)
 {
     ProcessPingResult(e);
 }
Ejemplo n.º 37
0
		protected void OnPingCompleted (PingCompletedEventArgs e)
		{
			if (PingCompleted != null)
				PingCompleted (this, e);
			user_async_state = null;
			worker = null;
		}
Ejemplo n.º 38
0
        private void OnPingCompleted(object sender, PingCompletedEventArgs e)
        {
            PingTaskState state = e.UserState as PingTaskState;
            if (state != null)
            {
                if (e.Cancelled || Executor.Command.Stopping)
                {
                    state.Ping.Dispose();
                    return;
                }

                PingHostInfo result = new PingHostInfo(this, state.IPAddress, e.Reply, e.Error, Buffer.Length);
                Executor.WriteInfo(result);

                if (state.RemainingCount == 0)
                {
                    state.Ping.Dispose();
                }
                else
                {
                    SendAsyncInternal(state);
                }
            }
        }
Ejemplo n.º 39
0
 protected void OnPingCompleted(PingCompletedEventArgs e)
 {
     PingCompleted?.Invoke(this, e);
 }
Ejemplo n.º 40
0
        private void PingComplete(object sender, PingCompletedEventArgs e)
        {
            if(!e.Cancelled && e.Error == null)
            {
                if(e.Reply.Status == IPStatus.Success)
                {

                    foundIPs.Add(e.UserState as IPAddress);

                    if(additionalResolving)
                    {
                        try
                        {
                            foundHosts.Add(Dns.GetHostEntry((e.UserState as IPAddress)));
                        }
                        catch(Exception ex)
                        {
                            if(debugMode)
                            {
                                stdOut.Error(ex.ToString(), (e.UserState as IPAddress).ToString());
                            }
                        }
                    }
                }
            }

            pingsToDo--;
        }
Ejemplo n.º 41
0
        protected void PingCallback(object sender, System.Net.NetworkInformation.PingCompletedEventArgs e)
        {
            // If the operation was canceled, display a message to the user.
            if (e.Cancelled)
            {
                Console.WriteLine("Ping canceled.");
                Disconnect(((ClientConnection)e.UserState).ThisID);
                ((Ping)sender).Dispose();
                PingsDoneCount++;
                if (PingsDoneCount >= Clients.Count)
                {
                    PingsDoneCount = 0;
                }
                return;
            }

            // If an error occurred, display the exception to the user.
            if (e.Error != null)
            {
                Console.WriteLine("Ping failed:");
                Disconnect(((ClientConnection)e.UserState).ThisID);
                ((Ping)sender).Dispose();
                PingsDoneCount++;
                if (PingsDoneCount >= Clients.Count)
                {
                    PingsDoneCount = 0;
                }
                return;
            }

            PingReply        reply = e.Reply;
            int              id    = ((int)e.UserState);
            ClientConnection cc    = null;

            if (!Clients.TryGetValue(id, out cc))
            {
                ((Ping)sender).Dispose();
                PingsDoneCount++;
                if (PingsDoneCount >= Clients.Count)
                {
                    PingsDoneCount = 0;
                }
                return;
            }

            if (!cc.ThisClient.Connected)
            {
                ((Ping)sender).Dispose();
                PingsDoneCount++;
                if (PingsDoneCount >= Clients.Count)
                {
                    PingsDoneCount = 0;
                }
                return;
            }

            cc.Ping = (int)(reply.RoundtripTime / 2);
            PacketDesc_Ping pkt = new PacketDesc_Ping();

            pkt.PacketTarget         = EConnectionType.CLIENT;
            pkt.PacketOriginClientID = UniqueID;
            pkt.ToServerLatency      = cc.Ping; // send clients one way to server latency
            SendPacketToClient(pkt, id);
            ((Ping)sender).Dispose();
            PingsDoneCount++;

            if (PingsDoneCount >= Clients.Count)
            {
                PingsDoneCount = 0;
            }
        }