Multithreaded Scanning?

Discussions about TWAIN & WIA scanning in GdPicture.NET using GdPictureImaging.
Post Reply
Gone2mars
Posts: 3
Joined: Fri Dec 03, 2010 9:11 am

Multithreaded Scanning?

Post by Gone2mars » Fri Dec 03, 2010 9:25 am

Hi,

The company i work for have been using GdTwain.ocx to scan for many years however i'm rewriting it for a .NET 2.0 application.

I've downloaded the GDPicture.NET trial and i'm currently trying to evaluate if it is worth upgrading from the ActiveX control to the new .NET control. The main reason i'm doing this is quite simply that i want to do my scanning in a multithreaded environment instead of on the UI thread.

For testing purposes, i've converted over the sample that is shipped with GDPicture called twain_sample and simply done the following:

Code: Select all

Private Sub Command1_Click '....
        If OpenSelectedSource() Then 'Opens the source just fine.
            Dim oThread As New Threading.Thread(AddressOf Start_Threaded)
            oThread.Start()
        End If
    End Sub

Private Sub Start_Threaded()

        'Here we will scan in a 1bpp ccitt4 & 200 DPI from adf to multipage tif file
        Dim nImageCount As Integer
        Dim ImageID As Integer
       
        nImageCount = 0

        oGdPictureImaging.TwainSetHideUI(True)
        oGdPictureImaging.TwainSetIndicators(False)

        oGdPictureImaging.TwainSetAutoFeed(True) 'Set AutoFeed Enabled
        oGdPictureImaging.TwainSetAutoScan(True) 'To  achieve the maximum scanning rate

        oGdPictureImaging.TwainSetResolution(200)
        oGdPictureImaging.TwainSetPixelType(TwainPixelType.TWPT_BW) 'Black & White
        oGdPictureImaging.TwainSetBitDepth(1) ' 1 bpp
        Do
            ImageID = oGdPictureImaging.TwainAcquireToGdPictureImage(0) 'Me.Handle)

            'ImageID will never get this far for the code to continue.

            If ImageID <> 0 Then
               
            End If
        Loop While oGdPictureImaging.TwainGetState > TwainStatus.TWAIN_SOURCE_ENABLED

    End Sub

The application will get to TwainAcquireToGdPictureImage but NEVER return. It simply hangs.

I've tried this out of a thread and the code works correctly and scans fine. I'm trying this on an Epson GT15000.

If it isn't possible to scan inside a thread then unfortunately i can't justify upgrading to GdPicture.NET as it is no different to the GDTwain.ocx version we already own :(

Regards,
Mark G

User avatar
Loïc
Site Admin
Posts: 5881
Joined: Tue Oct 17, 2006 10:48 pm
Location: France
Contact:

Re: Multithreaded Scanning?

Post by Loïc » Tue Dec 14, 2010 3:22 pm

Hi,

I am sorry for the delay, i forgot this post...

A call to TwainSetModalUI(False) and TwainSetIndicators(True) are needed for threading usage.

IE:

Code: Select all

oGdPictureImaging.TwainSetHideUI(True)
oGdPictureImaging.TwainSetIndicators(True)
oGdPictureImaging.TwainSetModalUI(False)
This should solve the problem.

Kind regards,

Loïc

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest