/// <summary> /// Stops listening and waits for all remote connections to close. /// </summary> public virtual void Stop() { if (!Active) { throw new InvalidOperationException("The server has not been started yet."); } Broadcast(new Command(null, Information, CommandType.Close)); Active = false; foreach (ClientObject client in Clients.Values) { client.Dispose(); } Clients.Clear(); if (ConnectionListener.IsAlive) { ConnectionListener.Interrupt(); ConnectionListener.Join(); } while (Clients.Count > 0) { } }