public void ForEachClient(ForEachClientDelegate whatToDo) { IClientAPI[] LocalClients; lock (m_clients) { LocalClients = new IClientAPI[m_clients.Count]; m_clients.Values.CopyTo(LocalClients, 0); } for (int i = 0; i < LocalClients.Length; i++) { try { whatToDo(LocalClients[i]); } catch (Exception e) { m_log.Warn("[CLIENT]: Unable to do ForEachClient for one of the clients" + "\n Reason: " + e.ToString()); } } }