Esempio n. 1
0
 /// <summary>
 /// 启动多线程爬行
 /// </summary>
 public void RunCrawler(TaskList taskList, int taskNum = 4)
 {
     TaskList = taskList;
     var tasks = new Task[taskNum];
     for (int i = 0; i < taskNum; i++)
     {
         tasks[i] = new Task(BaseWork);
         tasks[i].Start();
     }
     Task.WaitAll(tasks);
     TaskEntity.TaskStateDicId = 3;
     new TaskDomain().Update(TaskEntity);
 }
Esempio n. 2
0
 /// <summary>
 /// 获取唯一实例
 /// </summary>
 /// <returns></returns>
 public static TaskList GetInstance()
 {
     if (_taskList == null)
     {
         lock (SyncRoot)
         {
             if (_taskList == null)
             {
                 _taskList = new TaskList();
             }
         }
     }
     return _taskList;
 }