Tattakashi123 / t

Automatically exported from code.google.com/p/twaindotnet
0 stars 0 forks source link

Test App hangs when no paper is in scanner #38

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Don't put a paper in the scanner
2. Uncheck the 'Use UI' checkbox
2. Click the 'Scan' button

What is the expected output? What do you see instead?

I get a message from the scanner 'No Paper, (ID : 3040)' (Title: 'Source 
Message'). After that the Test App hangs and doesn't reactivate.

This behaviour is inherited in the application I'm currently working on because 
the Twain class doesn't respond any more after this message.

What version of the product are you using? On what operating system?

Latest source available, Windows XP SP 3

Original issue reported on code.google.com by jrunkel....@gmail.com on 1 Mar 2012 at 8:30

GoogleCodeExporter commented 8 years ago
After spending hours of debugging I found out that the solution is simple. The 
error occures because of a missing event raise in the DataSourceManager. Simply 
change lines 90ff from the original:

            finally
            {
                // Remove the message hook if scan setup failed
                if (!scanning)
                {
                    EndingScan();
                }
            }

to the fixed version, that is:

            finally
            {
                // Remove the message hook if scan setup failed
                if (!scanning)
                {
                    EndingScan();
                    try
                    {
                        ScanningComplete(this, new ScanningCompleteEventArgs(null);
                    }
                    catch { }
                }
            }

This way the DataSourceManager raises the ScanningComplete event which allows 
client applications to now that the scan run stopped. You can optionally submit 
a custom exception in the ScanningCompleteEventArgs constructor to indicate 
that the scan setup failed.

Original comment by jrunkel....@gmail.com on 1 Mar 2012 at 3:21

GoogleCodeExporter commented 8 years ago
Thank you very much!

Original comment by vincenor...@gmail.com on 21 Oct 2014 at 7:31