示例#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);
        }
        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);
            }
        }
示例#3
0
        public bool IsRunning(string crypto, string currency)
        {
            string key = PriceHub.GetKey(crypto, currency);

            return(_priceTaskStorage.Exists(key));
        }