public virtual void TestEventCountingPdfEvent()
        {
            MultiThreadingTest.TestEventCounter eventCounter = new MultiThreadingTest.TestEventCounter();
            IEventCounterFactory factory = new SimpleEventCounterFactory(eventCounter);

            EventCounterHandler.GetInstance().Register(factory);
            try {
                int       n        = 16;
                IMetaInfo metainfo = new TestMetaInfo();
                Thread[]  threads  = new Thread[n];
                for (int i = 0; i < n; i++)
                {
                    // We do not use Runnable as the variable's type because of porting issues
                    DoImageOcrRunnable runnable = new DoImageOcrRunnable(tesseractReader, metainfo, new FileInfo(sourceFolder
                                                                                                                 + "numbers_01.jpg"), new FileInfo(destinationFolder + "ocr-result-" + (i + 1) + ".txt"), 0 == i % 2);
                    threads[i] = GetThread(runnable);
                }
                for (int i = 0; i < n; i++)
                {
                    threads[i].Start();
                }
                for (int i = 0; i < n; i++)
                {
                    threads[i].Join();
                }
                NUnit.Framework.Assert.AreEqual(n, eventCounter.GetEvents().Count);
                int expectedPdfEvents   = n / 2;
                int expectedImageEvents = n - expectedPdfEvents;
                int foundPdfEvents      = 0;
                int foundImageEvents    = 0;
                for (int i = 0; i < n; i++)
                {
                    if (PdfOcrTesseract4Event.TESSERACT4_IMAGE_TO_PDF == eventCounter.GetEvents()[i])
                    {
                        foundPdfEvents++;
                    }
                    else
                    {
                        if (PdfOcrTesseract4Event.TESSERACT4_IMAGE_OCR == eventCounter.GetEvents()[i])
                        {
                            foundImageEvents++;
                        }
                    }
                    NUnit.Framework.Assert.AreEqual(metainfo, eventCounter.GetMetaInfos()[i]);
                }
                NUnit.Framework.Assert.AreEqual(expectedImageEvents, foundImageEvents);
                NUnit.Framework.Assert.AreEqual(expectedPdfEvents, foundPdfEvents);
            }
            finally {
                EventCounterHandler.GetInstance().Unregister(factory);
            }
        }
 private static Thread GetThread(DoImageOcrRunnable runnable)
 {
     return(new Thread(new ThreadStart(runnable.Run)));
 }