public bool Clear() { var principalName = BuildKey(string.Empty); foreach (var key in _clients.Keys.Where(q => q.StartsWith(principalName))) { IHttpClient client=null; var retries = 5; while (retries > 0) { var success = _clients.TryRemove(key, out client); if (success) break; Thread.Sleep(42); retries--; } if (client == null) { return false; } client.Abort(); client = null; } return true; }