public void AllTaskStartCommand() { lock (lockobject) { foreach (var item in this.DataCells.ToList().Where(c => c.Complated == false)) { if (ActiveThreadNum < MaxThreadNum) { var query = TaskThradManagement.Compontents.Where(c => c.CurrentDataCell.Id == item.Id); if (!query.Any()) { UploadCompontent compontent = new UploadCompontent(item); compontent.CompontentComplatedEvent += TaskThradManagement.OnCompontentComplated; TaskThradManagement.Compontents.Add(compontent); compontent.CreateCompontentWorkThrad(); compontent.Start(); ActiveThreadNum = ActiveThreadNum + 1; } } else { break; } } } }
protected void StatrtAllUploadThread(int id = -1) { var query = this.UploadEnities.Where(c => c.IsComplated == false); if (id != -1) { query = query.Where(c => c.Id == id); } if (query.Any()) { foreach (var entity in query) { if (workingThreadNum < MaxThreadNum) { UploadCompontent compontent = new UploadCompontent(entity); compontent.UploadCompontentComplatedEvent += this.ThreadManagement.OnCompontentComplated; compontent.CreateCompontentWorkThrad(); this.ThreadManagement.UploadCompontents.Add(compontent); compontent.Start(); WorkingThreadNUm = WorkingThreadNUm + 1; } else { break; } } } }