protected override async Task ExecuteAsync(CancellationToken stoppingToken) { while (!stoppingToken.IsCancellationRequested) { _logger.LogInformation("Publishing event at: {time}", DateTimeOffset.Now); var weather = _factory.CreateWeather(); await _daprClient.PublishEventAsync(Constants.PubSubName, "weather", weather); await Task.Delay(5000, stoppingToken); } }
protected override async Task ExecuteAsync(CancellationToken stoppingToken) { while (!stoppingToken.IsCancellationRequested) { _logger.LogInformation("Publishing event at: {Time}", DateTimeOffset.Now); // Create weather forecasts var weathers = _factory.CreateWeather(); // Publish event await _eventBus.PublishAsync(new WeatherForecastEvent(weathers), null, "v1"); await Task.Delay(5000, stoppingToken); } }