private void bgwMatch_DoWork(object sender, DoWorkEventArgs e) { while (true) { lock (locker) { if (ajEntities_Queue.Count > 0) { AJEntity aj = ajEntities_Queue.Dequeue(); string result = aj.LoadFiles(rootDir, fileFormat); if (!string.IsNullOrWhiteSpace(result)) { WriteErrorInfo(aj.Location.ToString(), "LoadFiles", result); } else if (aj.ScanFiles.Count != aj.Pages) { WriteErrorInfo(aj.Location.ToString(), "", "[扫描件][" + aj.ScanFiles.Count + "]与[案卷][" + aj.Pages + "]页数不相等"); } ajEntities_List.Add(aj); if (isOneToMany) { DataTable JNTotalTable = DataTableBuilder(JNCells); JNTotalView = JNTotalTable.AsDataView(); List <JNEntity> jns = FindJNEntity(aj); if (jns != null) { int totalPage = 0; foreach (JNEntity jn in jns) { totalPage += jn.Pages; } if (aj.Pages != totalPage) { WriteErrorInfo(aj.Location.ToString(), "", "[卷内][" + totalPage + "]与[案卷][" + aj.Pages + "]页数不相等"); } if (JNCountColumn != null) { if (aj.JNCount != jns.Count) { WriteErrorInfo(aj.Location.ToString(), "", "[件数][" + aj.JNCount + "]与[卷内条目数][" + jns.Count + "]不相等"); } } } Entities_Dic.Add(aj, jns); } } if (prepareAJComplete == true && ajEntities_List.Count == UsefulAJ) { break; } } } }