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

Does not work in Timer events

May 1, 2014 at 6:51 AM
My program is to get scan command from a table. So I create the Saraff TWAIN object in a timer event, it can work well in WIN7, but it does not work in Win XP.
Physical scanner can start after there is a command come, but once scan finished, the program will hange, I try to catch the exception in the AcquireCompleted event, but no response.
Can you give me any hint what's wrong? thx.
May 1, 2014 at 7:59 PM
Hello, xgc521.
I think that the error in your program. For example, the Saraff.Twain.Twain32 object must be created when the program starts, when the timer fires, then invoked the Acquire method.
May 2, 2014 at 2:30 AM
Hi Saraff,

please see the sample code like below, in fact I create Saraff.Twain.Twain32 object if it is null when the timer fires, it can work well in Win7 but does not work in WinXP.

private void timerScan_Tick(object sender, EventArgs e)
    if (twain321 ==null)
       twain321 = new Saraff.Twain.Twain32();

        twain321.ShowUI = false;
        twain321.AcquireCompleted += twain321_AcquireCompleted;

      twain321.SourceIndex =0;

May 2, 2014 at 6:59 AM
Edited May 2, 2014 at 11:17 AM
Hello, xgc521.
I think that there are not enough pairs of parentheses.
private void timerScan_Tick(object sender, EventArgs e) {
    try {
        if(this._twain32==null) {
            this._twain32=new Saraff.Twain.Twain32();

           //_twain32.SourceIndex=0; // this superfluous
    } catch(Exception ex) {
        // <<< exception handler
Marked as answer by SARAFF on 6/23/2014 at 12:30 PM
May 2, 2014 at 8:34 AM
Hi Saraff,

Thanks for your kind support, do you know anyone running previous code successfully in WinXP? I did not have a scanner now , so cannot validate it immediately.

Btw, if comment the SourceIndex setting code, it will use the default scanner (index is 0) ,correct?
May 2, 2014 at 11:15 AM
Edited May 2, 2014 at 11:30 AM
Hello, xgc521.
Saraff.Twain.NET was tested for Windows 2000 / XP / 2003 / Vista / 2008 / 7, 32-bit / 64-bit.
See Minimal implementation and Alternative User Interfaces