TwainAcquireToGdPictureImage inside worker thread
TwainAcquireToGdPictureImage inside worker thread
I am calling in to TWAIN to scan inside of a worker thread. The hook with my implementation is that the code to do all the TWAIN work is inside a Dll. What happens is that when we call TwainAcquireToGdPictureImage from that dll the code just hangs. If I call into the code to perform the scan outside of the thread the scan works fine. When inside of the thread everything works, opening the source, and even hiding/showing the TWAIN UI works in that if we show the TWAIN UI it shows the UI but then when we click "Scan" in the mftr's TWAIN UI it just hangs. Is there something odd about having the thread inside a dll and calling into TwainAcquireToGdPictureImage?
Thanks!
Thanks!
-
- Posts: 32
- Joined: Sun Jan 30, 2011 8:40 pm
Re: TwainAcquireToGdPictureImage inside worker thread
Try calling TwainCloseSourceManager from the original thread before the processing begins in the second thread. I was having the exact same problem (clicking Scan in the manufacturer's UI would cause app to freeze) and I believe this is what fixed it. I'll be interested to see if this works for you too.
Re: TwainAcquireToGdPictureImage inside worker thread
I am not opening the source manager at all. I open the source w/o using the source manager. And I am not opening two instances of twain scanning at the same time; only one. I am trying to separate TWAIN from the UI by having the UI in an app and the TWAIN scanning in a dll. The app calls into the TWAIN scanning and I want that in a thread so the app can go and and do it's thing while the scanning is happening. Unfortunately there seems to be some threading problem with the GDPicture component where it locks up upon scanning while it is in a thread. I have seen the example code that GDPicture provides for scanning inside of a thread and I am implementing that arrangement. Albeit in a dll.
Re: TwainAcquireToGdPictureImage inside worker thread
Update: By adding a TwainCloseSource prior to opening the source allows the scan to come off as expected. Odd.
Re: TwainAcquireToGdPictureImage inside worker thread
Well, let's check that....if IntPtr window handle is null for all the Twain calls it works inside the thread otherwise if you actually pass it a real windows handle it locks up. Is there something special that I have to do with the thread in order for this to work?
Who is online
Users browsing this forum: No registered users and 1 guest