コード例 #1
0
        public async Task <CosmosDbLivySession> GetSessionAsync()
        {
            var availableSession = await GetAvailableSessionFromPoolAsync().ConfigureAwait(false);

            if (availableSession != null)
            {
                return(availableSession);
            }

            if (_sessions.Count >= _maxSessions)
            {
                return(await _sessions.FirstCompletedAsync(t => t.WaitForSessionAsync()).ConfigureAwait(false));
            }

            var session = new CosmosDbLivySession(_client, _cosmosCollectionSettings, _livySessionConfiguration);

            _sessions.Add(session);

            return(session);
        }