public void OnThreadAbort(cGatherTaskThreadItem item) { lock (locker) { this.ThreadNum--; if (this.ThreadNum == 0) { this.OnThreadAllCompleted(); } } }
public void Start() { while (this.GatherTaskType == EnumGloabParas.EnumGatherTaskType.Noraml) { System.Threading.Thread.Sleep(100); } startTime = DateTime.Now; if (m_TaskItemEntity == null) { throw new Exception("_taskItemEntity is null"); } if (this.ThreadNum == 0) { throw new Exception("ThreadNum is null"); } if (this.GaterherState == EnumGloabParas.EnumThreadState.SpiderCompleted) { this.OnThreadAllCompleted(); return; } //任务暂停,再重启不用获取主网页 if (this.GaterherState != EnumGloabParas.EnumThreadState.Suspended) { ThreadGetMainUrlsWork(); } threadItemList = new List <cGatherTaskThreadItem>(); this.m_ThreadState = EnumGloabParas.EnumThreadState.Run; completeThreadList = new List <string>(); this.GaterherState = EnumGloabParas.EnumThreadState.Run; for (var i = 0; i < this.ThreadNum; i++) { cGatherTaskThreadItem threadItem = new cGatherTaskThreadItem(this, i); threadItem.e_TotalCount += new OnGatherTotalCount(cGatherTaskManage_e_TotalCount); threadItem.e_CompleteCount += new OnGatherCompleteCount(threadItem_e_CompleteCount); threadItem.e_OnGatherNotityCompleted += new OnGatherNotityCompleted(threadItem_e_OnGatherNotityCompleted); threadItem.e_OnGatherDataCompleted += new OnGatherDataCompleted(threadItem_e_OnGatherDataCompleted); threadItem.m_GatherData = GetDataTable(); threadItem.ThreadState = EnumGloabParas.EnumThreadState.Run; this.threadItemList.Add(threadItem); threadItem.Start(); } }