Пример #1
0
        private void CreatePollingPrice(string crypto, string currency, CancellationToken cancellationToken)
        {
            string groupName = PriceHub.GetKey(crypto, currency);

            while (!cancellationToken.IsCancellationRequested)
            {
                Thread.Sleep(10000);
                var response = _cryptoProvider.GetPrice(crypto, currency).GetAwaiter().GetResult();
                _hubContext.Clients.Group(groupName).SendPrice(response);
            }
        }
Пример #2
0
        public async Task <IActionResult> GetPrice(string crypto, string currency)
        {
            if (!_priceHubPool.IsRunning(crypto, currency))
            {
                _priceHubPool.Start(crypto, currency);
            }

            var response = await _cryptoProvider.GetPrice(crypto, currency);

            return(Ok(response));
        }