Esempio n. 1
0
        public async Task <IEnumerable <WeatherForecast> > Get()
        {
            _logger.LogInformation($"AspNet Core Thread Id: {Thread.CurrentThread.ManagedThreadId} starts execution in {nameof(Get)}.");

            var forecastServiceTask = _forecastService.GetTodaysForecastAsync();

            for (int i = 0; i < 20; i++)
            {
                _logger.LogInformation($"AspNet Core Thread Id: {Thread.CurrentThread.ManagedThreadId} does synchronous work in {nameof(Get)}.");
            }

            var result = await forecastServiceTask;

            _logger.LogInformation($"AspNet Core Thread Id: {Thread.CurrentThread.ManagedThreadId} about to return result from {nameof(Get)}.");

            return(result);
        }