Example #1
0
        static async Task Main(string[] args)
        {
            IWeatherInfoManager manager = WeatherInfoServiceFactory.GetWeatherInfoManager();
            BasicWeatherInfo    info    = await manager.GetWeatherInfoAsync("Kiev");

            manager.ShowWeatherInfo(info);
            await manager.SaveWeatherInfoAsync(info);

            Console.ReadKey();
        }
Example #2
0
        public virtual async Task <BasicWeatherInfo> GetWeatherInfoAsync(string city)
        {
            List <Task <BasicWeatherInfo> >   tasks    = new List <Task <BasicWeatherInfo> >();
            IEnumerable <IWeatherInfoService> services = WeatherInfoServiceFactory.GetWeatherServices();

            services.ForEach(service => tasks.Add(service.GetWeatherInfoAsync(city)));
            BasicWeatherInfo result = await tasks.GetFirstSuccessfulTask();

            return(result);
        }