OS: Windows 7 64-bit
I'm currently using the evaluation version of VintaSoftTwain.NET version 18.104.22.168
I am creating a thread with an AcqiureModal loop inside of that thread.
The problem is that the first call to AcquireModal runs on the main thread despite being called from inside of a different thread.
All other calls to AcquireModal after the first one execute in the thread that they are called from.
This causes the windows form to freeze until the after first page finishes scanning at which point any further pages being scanned do not freeze the windows form.
Code: Select all
Private Sub BeginAquire(ByVal pDevice As Vintasoft.Twain.Device) Dim trdAcquire As System.Threading.Thread = New System.Threading.Thread(AddressOf AcquireThread) trdAcquire.Start(pDevice) End Sub Private Sub AcquireThread(ByVal pDevice As Object) Dim Dev As Vintasoft.Twain.Device = DirectCast(pDevice, Vintasoft.Twain.Device) Dim ModalState As Vintasoft.Twain.AcquireModalState = AcquireModalState.None Do ModalState = Dev.AcquireModal() ' First time through the loop, this is run on Main Thread Select Case ModalState Case AcquireModalState.ImageAcquiring While Dev.AcquiredImages.Count = 0 End While SaveImage(Dev.AcquiredImages.Last) Case AcquireModalState.ImageAcquired SaveImage(Dev.AcquiredImages.Last) Case AcquireModalState.ScanCompleted _device_ScanCompleted(Nothing, Nothing) Case AcquireModalState.ScanCanceled If Dev.State = DeviceState.Opened Then ' close the device Dev.Close() End If Case AcquireModalState.ScanFailed If Dev.State = DeviceState.Opened Then ' close the device Dev.Close() End If End Select Loop While ModalState <> AcquireModalState.None End Sub