Exemplo n.º 1
0
        public void BeginProcess(int n)
        {
            Thread[]    tasks   = new Thread[n];
            WebParser[] parsers = new WebParser[n];

            for (int i = 0; i < n; i++)
            {
                WebParser parser = new WebParser();
                parsers[i] = parser;
                tasks[i]   = new Thread(parser.run);
                tasks[i].Start();
            }



            while (true)
            {
                Thread.Sleep(2500);
                bool active = false;
                foreach (var parser in parsers)
                {
                    active = active || parser.alive;
                }
                if (!active)
                {
                    end = true;
                    return;
                }
            }
        }
Exemplo n.º 2
0
        public void BeginProcess(Object _n)
        {
            end = false;
            int n = (int)_n;

            System.Console.WriteLine("Process started");
            Thread[]    tasks   = new Thread[n];
            WebParser[] parsers = new WebParser[n];

            for (int i = 0; i < n; i++)
            {
                WebParser parser = new WebParser();
                parsers[i] = parser;
                tasks[i]   = new Thread(parser.run);
                tasks[i].Start();
            }



            while (true)
            {
                Thread.Sleep(2500);
                skippedChanges();
                bool active = false;
                foreach (var parser in parsers)
                {
                    active = active || parser.alive;
                }
                if (!active)
                {
                    end = true;
                    skippedChanges();
                    endOfSearch();
                    return;
                }
                if (end)
                {
                    return;
                }
            }
        }