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); } }
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)); }