public async Task Start() { _priceHistory = new List <IPrice>(await _priceService.GetAllPrices()); _priceGenerator = Observable .Interval(TimeSpan.FromMilliseconds(250)) .Delay(TimeSpan.FromMilliseconds(50)) .Subscribe(async _ => { var asset = TradeServiceReferential.Assets.Random(); var price = CreatePrice(asset); await _priceService.CreatePrice(price); _priceHistory.Add(price); await _priceHub.RaiseChange(price); }); _dispose.Add(_priceGenerator); }
public Task StartAsync(CancellationToken token) { var priceGenerator = Observable .Interval(TimeSpan.FromMilliseconds(250)) .Delay(TimeSpan.FromMilliseconds(50)) .Subscribe(async _ => { _priceHistory = await _priceService.GetAllPrices(); var asset = TradeServiceReferential.Assets.Random(); var request = CreatePriceRequest(asset); var price = await _priceService.CreatePrice(request); await _priceHubService.Current.Proxy.RaiseChange(price); }); _cleanUp.Add(priceGenerator); return(Task.CompletedTask); }