Esempio n. 1
0
        public static void RunJob(ScrapeJob job)
        {
            bool startThread = false;

            lock (jobsLock)
            {
                Jobs.Add(job);
                if (!running)
                {
                    running     = true;
                    startThread = true;
                }
            }

            if (startThread)
            {
                ThreadPool.QueueUserWorkItem(new WaitCallback(Scraper.MyThread), null);
            }
        }
Esempio n. 2
0
        public static void MyThread(object state)
        {
            ScrapeJob job = null;

            lock (jobsLock)
            {
                if (Jobs.Count > 0)
                {
                    job = Jobs[0];
                    Jobs.RemoveAt(0);
                }
                else
                {
                    running = false;
                    return;
                }
            }

            Scraper s = new Scraper();

            s.Run();
        }