public void Start(string crypto, string currency) { string key = PriceHub.GetKey(crypto, currency); var cancellationTokenSource = new CancellationTokenSource(); var task = _priceTaskFactory.CreatePollingPriceTask(crypto, currency, cancellationTokenSource.Token); _priceTaskStorage.Add(key, task, cancellationTokenSource); }
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 bool IsRunning(string crypto, string currency) { string key = PriceHub.GetKey(crypto, currency); return(_priceTaskStorage.Exists(key)); }