Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1260
Infragistics BarcodeReder strange behaviour 2.
posted

This question is an extension to Infragistics BarcodeReder strange behaviour.

While I got my question solved in the previous question then the barcode reader control still behaves strange.

I have been trying to fix this, but somehow it's like it doesn't really want what I want.

To explain the problem short then it is like this:

1st approach:
I have a file watcher which is starting a background worker every time there is a new file in a certain folder.
This background worker uses Infragistics BarcodeReader to decode a QR code.

This works good when there is only one new file in the folder at a time.

As soon as there are more than one file then a System.InvalidOperationException: The calling thread cannot access this object because a different thread owns it. is thrown at _barcodeReader.Decode(BitmapFromUri(new Uri(_fullPath))); . And the strange thing is that this exception is not thrown for all files, but only some of them. And every time it is another amount of exceptions.

ExpceptionMessage: The calling thread cannot access this object because a different thread owns it.
ExceptionBody: System.InvalidOperationException: The calling thread cannot access this object because a different thread owns it.
   at System.Windows.Threading.Dispatcher.VerifyAccess()
   at System.Windows.Media.Imaging.BitmapSource.get_DpiX()
   at Infragistics.Controls.Barcodes.ImageProcessing.CreateImageFromPixelsArray(Byte[][] data, ImageData imageData, Boolean isImageZoomed)
   at Infragistics.Controls.Barcodes.BarcodeReader.Decode(BitmapSource bitmap, Symbology symbologyTypes)
   at QrDecoderWpf.MyBarcodeReader.DecodeQr() in C:\Users\nawed\Desktop\WorkSpaceVS\TestApplication\QrDecoderWpf\MyBarcodeReader.cs:line 50

With this approach 50% of the QR codes were not giving any result and there were around 10% exceptions

2nd Approach:
This approach is not creating a background worker, and is using BarcodeReader directly to decode QR.
This approach is very slow and time consuming, therefor I prefer the 1st approach with the background worker.
With this approach there were no exceptions and the amount of QR codes decoded were around 90-95%, but around 10% of those 90% had a very strange code like 025, 343, 23425,25266 or 2525. Normally all our QR codes are formatted like DDCCDDDDDDDD.DDD.DD where D = digit (0-9) and C = character (A-Z).

This has frustrated me for very long time now, I hope you guys can help me out.

Thanks in advance!

A sample project with PDF's can be found here https://we.tl/hnKOJBjQ9R (Link available untill 24 November 2016)