private static async Task SimulateDeviceAsync( Device device, Func <EventEntry[]> produceEventsForScenario, Func <object, Task <bool> > sendEventsAsync, TimeSpan waitBeforeStarting, IObserver <int> totalCount, CancellationToken token) { ScenarioSimulatorEventSource.Log.WarmingUpFor(device.Id, waitBeforeStarting.Ticks); try { await Task.Delay(waitBeforeStarting, token); } catch (TaskCanceledException) { return; } var messagingEntries = produceEventsForScenario(); device.ObservableEventCount .Sum() .Subscribe(total => ScenarioSimulatorEventSource.Log.FinalEventCount(device.Id, total)); device.ObservableEventCount .Subscribe(totalCount.OnNext); await device.RunSimulationAsync(messagingEntries, sendEventsAsync, token).ConfigureAwait(false); }
private static async Task SimulateDeviceAsync( Device device, Func<EventEntry[]> produceEventsForScenario, Func<object, Task<bool>> sendEventsAsync, TimeSpan waitBeforeStarting, IObserver<int> totalCount, CancellationToken token) { ScenarioSimulatorEventSource.Log.WarmingUpFor(device.Id, waitBeforeStarting.Ticks); try { await Task.Delay(waitBeforeStarting, token); } catch (TaskCanceledException) { return; } var messagingEntries = produceEventsForScenario(); device.ObservableEventCount .Sum() .Subscribe(total => ScenarioSimulatorEventSource.Log.FinalEventCount(device.Id, total)); device.ObservableEventCount .Subscribe(totalCount.OnNext); await device.RunSimulationAsync(messagingEntries, sendEventsAsync, token).ConfigureAwait(false); }