Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using (IDataReader dr = q.ExecuteReader())
- {
- ThreadPool.SetMaxThreads(10, 10);
- int workerThreads = 0;
- int completionPortThreads = 0;
- while (dr.Read())
- {
- do
- {
- ThreadPool.GetAvailableThreads(out workerThreads, out completionPortThreads);
- if (workerThreads == 0)
- {
- Thread.Sleep(100);
- }
- } while (workerThreads == 0);
- Database.Log l = new Database.Log();
- l.Load(dr);
- ThreadPool.QueueUserWorkItem(delegate(object threadContext)
- {
- Database.Log log = threadContext as Database.Log;
- Scraper scraper = new Scraper();
- dc.Product p = scraper.GetProduct(log, log.Url, true);
- ManualResetEvent done = new ManualResetEvent(false);
- done.Set();
- }, l);
- }
- }
Add Comment
Please, Sign In to add comment