Example #1
0
        public async override Task HandleAsync(WeatherForecastRequestedEvent @event)
        {
            _logger.LogInformation("Weather forecast requested");

            // Create weather forecasts after a 5 second delay (to simulate latency)
            int delaySeconds = 5;
            var weathers     = await _factory.CreateWeather(delaySeconds);

            // Publish event
            await _eventBus.PublishAsync(new WeatherForecastGeneratedEvent(weathers), null, "v1");
        }
Example #2
0
        public void WeatherDataAsync()
        {
            AsyncManager.OutstandingOperations.Increment();
            WeatherInfo weatherInfo = HttpContext.Cache[WeatherCacheName] as WeatherInfo;

            if (weatherInfo == null)
            {
                Weather weather = WeatherFactory.CreateWeather();
                weather.GetWeatherInfoAsync(GotWeatherInfo,
                                            error =>
                {
                    SetError(error);
                    GotWeatherInfo(null, true);
                }
                                            );
            }
            else
            {
                GotWeatherInfo(weatherInfo, true);
            }
        }