Exemple #1
0
        public T UpdateOrWait()
        {
            var wasInprogress = _updateIsInProgress.Value;

            using (_semaphor.Enter())
            {
                if (!wasInprogress)
                {
                    LoadValueWithRetryAsync().Wait();
                }

                return(_value);
            }
        }
Exemple #2
0
        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,
                })));
            }
        }