Example #1
0
        private void RefreshControl()
        {
            if (this.InvokeRequired)
            {
                BeginInvoke(new MethodInvoker(RefreshControl));
                return;
            }

            ClientTable.SuspendLayout();
            ClientTable.Rows.Clear();
            try
            {
                if (IsTcpAppServer)
                {
                    TcpAppServer appServer = Server as TcpAppServer;
                    //Thread lock to prevent race condition.
                    lock (appServer.AppClients)
                    {
                        foreach (TcpAppServerConnection c in appServer.AppClients)
                        {
                            ClientTable.Rows.Add(
                                c.Name + " | " + c.Connection.ClientIPAddress.ToString(),
                                c.Connection.Connected ? "Connected" : "-"
                                );
                        }
                    }
                }
                else
                {
                    foreach (TcpServerConnection c in Server.Clients)
                    {
                        ClientTable.Rows.Add(
                            c.ClientIPAddress.ToString(),
                            c.Connected ? "Connected" : "-"
                            );
                    }
                }
            }
            finally { ClientTable.ResumeLayout(); }
        }