This project has moved. For the latest updates, please go here.

using library not directly from a FORM

Jun 26, 2013 at 10:08 PM
Hi,
when I use the library from a form everything works fine. But when I try to call from another component inside a form like a pageTab it never start to scan.

When I create the Saraff.Twain.Twain32 twainDevice = new Saraff.Twain.Twain32();__ I setup the parent window on this.twainDevice.Parent = (Form)this.Parent.Parent; But it never scan.

I look inside the Twain32.cs in Acquire method and you are validating if !Application.MessageLoop and in my test that is true.

What Can I do?

Thank you,
Coordinator
Jun 27, 2013 at 7:13 AM
Edited Jun 27, 2013 at 7:25 AM
Hello, diamelma.
Twain32.Parent property mast be like System.Windows.Forms.Form or null. In your example, it is better not to set the Twain32.Parent property at all.
For more information you can view the source code of Saraff.Twain.Sample2 and Saraff.Twain.Sample3.
Marked as answer by SARAFF on 6/23/2014 at 12:47 PM
Jun 27, 2013 at 9:08 PM
Hi, I found the problems, I have the next code:

line 1: twainDevice.Acquire();
line 2: Image image =twainDevice.GetImage(0);
line 3: twainDevice.CloseDSM();

And the problem is while the scanning is processing (line 1) the application continue with the next lines of code line 2 and line 3 and first the closeDSM() is executed before the scanner start to scan.

If I implement some lines of code between twainDevice.Acquire(); and twainDevice.CloseDSM(); the application have a few time to finish acquisition and then close session. But the library should wait until it scan the hole pages and after that get out from Acquire method and continue the next steps.

Thanks you,
Coordinator
Jun 28, 2013 at 5:07 AM
Hello, diamelma.
See source code of Saraff.Twain.Sample2.
The class Saraff.Twain.Twain32 have event AcquireCompleted (public event EventHandler AcquireCompleted) that occurs when the scan is complete.