Esempio n. 1
0
        /// <summary>
        /// Работает только с самым последним изображением, если изображений становится больше, чем обработчиков, лишние отбрасываются.
        /// </summary>
        /// <param name="cancellationToken"></param>
        public void MainProcessImage(object cancellationToken)
        {
            CancellationToken token = (CancellationToken)cancellationToken;

            while (!token.IsCancellationRequested)
            {
                PhaseImage result = null;
                while (MainProcessingQuenue.TryDequeue(out result))
                {
                    if (result != null)
                    {
                        logger.Debug(string.Format("Processing image (recorded at {0})", result.RecordingTime));
                        result.CalculatePhaseImage();
                        result.Unwrap();
                        result.Process();
                        if (PhaseImageInterfaceSender != null)
                        {
                            PhaseImageInterfaceSender.Invoke(result);
                        }
                    }
                    while (MainProcessingQuenue.TryDequeue(out result) && !MainProcessingQuenue.IsEmpty)
                    {
                        ;
                    }

                    //logger.Debug(string.Format("Decuenue image (rec. time: {1}) from processing queue. Total {0} images in queue.", MainProcessingQuenue.Count, result.RecordingTime));
                    //if (!MainProcessingQuenue.IsEmpty)
                    //{
                    //    logger.Debug("Using additional threads");
                    //    if (SecondaryImageProcessors!=null)
                    //        SecondaryProcessingQuenue.Enqueue(result);
                    //}
                    //else
                    //{
                    //    logger.Debug("Processing image in main thread additional threads");
                    //    if (result != null)
                    //    {
                    //        logger.Debug(string.Format("Processing image (recorded at {0})", result.RecordingTime));
                    //        result.CalculatePhaseImage();
                    //        result.Unwrap();
                    //        result.Process();
                    //        if (PhaseImageInterfaceSender != null)
                    //            PhaseImageInterfaceSender.Invoke(result);
                    //        if (PhaseImageSender != null)
                    //            PhaseImageSender.Invoke(result);
                    //    }
                    //    else
                    //    {
                    //        logger.Debug("No images in queue");
                    //    }
                    //}
                }

                //Thread.Sleep(50);
            }
        }
Esempio n. 2
0
 public static void Calc()
 {
     while (phaseImages.Count != 0)
     {
         PhaseImage phaseIm = phaseImages.Dequeue();
         phaseIm.CalculatePhaseImage();
         phaseIm.Unwrap();
         //phaseIm.Process();
     }
 }