Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
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);
            }
        }
Ejemplo n.º 3
0
        public bool IsRunning(string crypto, string currency)
        {
            string key = PriceHub.GetKey(crypto, currency);

            return(_priceTaskStorage.Exists(key));
        }