I have an object that interfaces to a TWAIN device. The object raises events after each scan. The GUI subscribes to these events to get the image that was scanned, error events, and some other information about the scan. I execute the functionality in single threaded winform (.net 3.5) application.
Because the scanning can take 10 seconds, and it hogs the thread on the UI so it becomes unresponsive, i would like to run the scan on a background thread.
Can someone show me how to do this in a way that the events that the Twain object raises are handled safely?
Currently:
1. Create instance of TwScan
2. Hook events to listen to.
3. Invoke StartScan method on the instance
as scanning proceeds, my winform handles the events.
How to modify to operate the TwScan on the background thread, yet have the events raised on the UI thread?
Start Free Trial