private static void CreateThumbnail(BlockingCollection <BitmapWithFilePathAndSeq> inputQueue, BlockingCollection <BitmapWithFilePathAndSeq> outputQueue, CancellationTokenSource cts)
        {
            CancellationToken token = cts.Token;

            try
            {
                foreach (var input in inputQueue.GetConsumingEnumerable())
                {
                    if (token.IsCancellationRequested)
                    {
                        break;
                    }
                    var result = ImageProcessor.ResizeToThumbnail(input.Image);

                    outputQueue.Add(new BitmapWithFilePathAndSeq()
                    {
                        FilePath = input.FilePath,
                        Image    = (Bitmap)result.Clone(),
                        SeqId    = input.SeqId,
                    }, token);
                }
            }
            catch (Exception ex)
            {
                if (!(ex is OperationCanceledException))
                {
                    cts.Cancel();
                    throw;
                }
            }
            finally
            {
                outputQueue.CompleteAdding();
            }
        }
        /// <summary>
        /// Executes a image processing operation.
        /// </summary>
        /// <param name="filePath">Path to the file image to process.</param>
        /// <param name="background_bm">The background image.</param>
        private static void ExecuteSequentialOperation(string filePath, Bitmap background_bm)
        {
            Bitmap target_bm = ImageProcessor.LoadFileAsImage(filePath);

            target_bm = ImageProcessor.RemoveBackground(target_bm, background_bm);
            Bitmap target_thumb_bm = ImageProcessor.ResizeToThumbnail(target_bm);

            string output       = OutputDirectory + Path.DirectorySeparatorChar + Path.GetFileName(filePath);
            string output_thumb = OutputDirectory + Path.DirectorySeparatorChar + Path.GetFileNameWithoutExtension(filePath) + "_thumbnail" + Path.GetExtension(filePath);

            ImageProcessor.SaveBitmapToFile(target_bm, output);
            ImageProcessor.SaveBitmapToFile(target_thumb_bm, output_thumb);
        }