/// <summary> /// If use multithread, than gabor featrue will not be extracted. /// </summary> /// <param name="argus"></param> public void AsynImportClothPics(ImportArgus argus) { if (argus.PicNames == null || argus.PicNames.Count == 0) { return; } if (argus.PicNames.Count < argus.ThreadNum) { argus.ThreadNum = argus.PicNames.Count; } else if (argus.ThreadNum <= 0) { argus.ThreadNum = 1; } else if (argus.ThreadNum > SearchConstants.MAX_IMPORT_THREADS) { argus.ThreadNum = SearchConstants.MAX_IMPORT_THREADS; } ParameterizedThreadStart threadDelegate = new ParameterizedThreadStart(importClothPics); Thread importPicsThread = new Thread(threadDelegate); importPicsThread.IsBackground = true; importPicsThread.Start(argus); }
private void importClothPics(Object obj) { ImportArgus argus = (ImportArgus)obj; List <String> picNames = argus.PicNames; // show progress win argus.BefDel(picNames.Count); Queue picNameQueue = Queue.Synchronized(new Queue(picNames)); // finished pictures //nFinished = 0; ParameterizedThreadStart threadDelegate = new ParameterizedThreadStart(importClothPicThread); Thread[] threads = new Thread[argus.ThreadNum]; bool isGabor = (argus.ThreadNum == 1); for (int i = 0; i < threads.Length; ++i) { threads[i] = new Thread(threadDelegate); threads[i].IsBackground = true; threads[i].Priority = ThreadPriority.BelowNormal; threads[i].Start(new ImportThreadArgus(picNameQueue, argus.Step, argus.StopImport, argus.StepDel, isGabor)); } for (int i = 0; i < threads.Length; ++i) { threads[i].Join(); } argus.AfterDel(); }