예제 #1
0
        public bool Update()
        {
            Ready        = false;
            Total        = 0;
            FinishedCity = 0;
            Task <List <CityTemp> > getCitiesTask = new Task <List <CityTemp> >(() => ParserEngine.getCities());

            getCitiesTask.Start();
            List <CityTemp> list = getCitiesTask.Result;

            Total = list.Count;
            Task[] tasks = list.Select(x => new Task(() => ParserEngine.FillCity(x, Notify))).ToArray();
            tasks.ToList().ForEach(x => x.Start());
            Task.WaitAll(tasks);
            writeToDB(list);
            Ready = true;
            return(true);
        }
예제 #2
0
        public static void Main(string[] args)
        {
            //russian console output
            Console.OutputEncoding = Encoding.UTF8;
            Console.WriteLine("GisMeteoParser start");

            Console.Write("Getting cities list: ");
            Task <List <CityTemp> > getCitiesTask = new Task <List <CityTemp> >(() => ParserEngine.getCities());

            getCitiesTask.Start();
            List <CityTemp> list = getCitiesTask.Result;

            Console.WriteLine("found {0} cities", list.Count);
            Console.WriteLine("Getting detailed forecast for tommorow:");

            Task[] tasks = list.Select(x => new Task(() => ParserEngine.FillCity(x))).Where(x => { x.Start(); return(true); }).ToArray();

            Task.WaitAll(tasks);

            writeToDB(list);
        }