public static void WorkerThread(object extractor) { ExtractorServer.KeyExtractor keyExtractor = (ExtractorServer.KeyExtractor)extractor; while (!keyExtractor.StopFlag) { while (keyExtractor.BreakFlag) { keyExtractor.Breaked = true; if (!keyExtractor.StopFlag) { Thread.Sleep(30); } else { break; } } keyExtractor.Breaked = false; BcDevices bcDevices = keyExtractor.Device; try { Engine.Initialize(0U); using (Engine engine = new Engine()) { while (!keyExtractor.BreakFlag && !keyExtractor.StopFlag) { FaceFrame orDefault = LimitedConcurrentQueueExtensions.GetOrDefault <FaceFrame>(ExtractorServer._faceframes); if (orDefault == null) { Thread.Sleep(10); } else { byte[] template = ExtractorServer.ExtractTemplate(orDefault, (IEngine)engine); bcDevices.AddKeyFrame(new KeyFrame() { Frame = orDefault, Key = template }); ++bcDevices.ExtractCount; } } } } catch (Exception ex) { ExtractorServer.Logger.Error((object)string.Concat(new object[4] { (object)"Extractor Thread Error ", (object)ex.Message, (object)" Extractor Index ", (object)ExtractorServer.Extractors.IndexOf(keyExtractor) })); } } keyExtractor.Stopped = true; }