public T UpdateOrWait() { var wasInprogress = _updateIsInProgress.Value; using (_semaphor.Enter()) { if (!wasInprogress) { LoadValueWithRetryAsync().Wait(); } return(_value); } }
public DiscordConnectionWrapper GetConnectionForToken(string token) { using (mutex.Enter()) { if (connections.TryGetValue(token, out var connection)) { return(connection); } return(connections[token] = new DiscordConnectionWrapper(new DiscordClient(new DiscordConfiguration { Token = token, TokenType = TokenType.Bot, }))); } }