first thread was deleted in error, so another one.
Problem: When cancelling the scan process in the scanner driver's progress dialog, the application does not respond anymore. It seems that the method-call of "AcquireModal" does not return in this case (the switch-line is never reached). Here is the code:
Code: Select all
bool bFinished = false;
Device deScan = null;
DeviceManager dmScan = null;
AcquireModalState amsScan;
try
{
TwainEnvironment.EnableDebugging(@"c:\vstwain.log");
dmScan = new DeviceManager(this);
dmScan.Open();
dmScan.ShowDefaultDeviceSelectionDialog();
deScan = dmScan.DefaultDevice;
deScan.Open();
deScan.ShowUI = false;
deScan.ModalUI = true;
deScan.ShowIndicators = true;
deScan.DisableAfterAcquire = true;
deScan.TransferMode = Vintasoft.Twain.TransferMode.Native;
deScan.DocumentFeeder.Enabled = true;
deScan.PixelType = Vintasoft.Twain.PixelType.BW;
deScan.Resolution = new Resolution(150, 150);
do
{
amsScan = deScan.AcquireModal();
switch (amsScan)
{
case AcquireModalState.ImageAcquired:
deScan.AcquiredImage.Dispose();
break;
case AcquireModalState.ScanCanceled:
case AcquireModalState.ScanCompleted:
case AcquireModalState.ScanFailed:
case AcquireModalState.UserInterfaceClosed:
case AcquireModalState.None:
bFinished = true;
break;
}
}
while (!bFinished);
MessageBox.Show("Finished");
}
catch (Exception eError)
{
MessageBox.Show(eError.Message);
}
finally
{
if (deScan != null && deScan.State != DeviceState.Closed)
{
deScan.Close();
deScan.Dispose();
}
if (dmScan != null && dmScan.State != DeviceManagerState.Closed)
{
dmScan.Close();
dmScan.Dispose();
}
}
The twain debug log:
Code: Select all
24.11.2015 16:18:28 29,532,160 Debugging enabled [9.1.5.1]
24.11.2015 16:18:28 29,585,408 Device manager is opening PathToDSM=C:\Windows\TWAIN_32.DLL
24.11.2015 16:18:28 29,593,600 DeviceManagerStateChanged Closed => Loaded
24.11.2015 16:18:28 29,593,600 DeviceManagerStateChanged Loaded => Opened
24.11.2015 16:18:28 29,593,600 Device manager is opened
24.11.2015 16:18:29 29,798,400 Device is opening
24.11.2015 16:18:30 31,526,912 DeviceStateChanged Closed => Opened
24.11.2015 16:18:30 31,535,104 Device is opened: Id(52), Version(1, 0, 13, 1, December, 2001), Protocol(1.9), Groups(3), Manuf(Hewlett-Packard), ProdFamily(All-in-One), ProdName(hp scanjet 5590 TWAIN)
24.11.2015 16:18:30 31,653,888 Getting value of capability Name=SupportedCaps Method=Get
24.11.2015 16:18:30 31,682,560 UsageMode=Get
24.11.2015 16:18:30 31,682,560 ContainerType=Array
24.11.2015 16:18:30 31,711,232 ValueType=UInt16
24.11.2015 16:18:30 31,715,328 Capability value is received
24.11.2015 16:18:30 31,752,192 Getting value of capability Name=FeederEnabled Method=GetCurrent
24.11.2015 16:18:30 31,752,192 UsageMode=Get, Set, GetDefault, Reset
24.11.2015 16:18:30 31,752,192 ContainerType=OneValue
24.11.2015 16:18:30 31,752,192 ValueType=Bool CurrentValue=True
24.11.2015 16:18:30 31,760,384 Capability value is received
24.11.2015 16:18:30 31,772,672 Setting value of capability Name=FeederEnabled ValueType=System.Boolean Value=True
24.11.2015 16:18:30 31,797,248 Result: Success
24.11.2015 16:18:30 31,797,248 Capability value is set
24.11.2015 16:18:30 31,817,728 Setting value of capability Name=IPixelType ValueType=System.UInt16 Value=0
24.11.2015 16:18:30 31,817,728 Result: Success
24.11.2015 16:18:30 31,817,728 Capability value is set
24.11.2015 16:18:30 31,825,920 Setting value of capability Name=IXResolution ValueType=System.Single Value=150
24.11.2015 16:18:30 31,838,208 Result: Success
24.11.2015 16:18:30 31,838,208 Capability value is set
24.11.2015 16:18:30 31,838,208 Setting value of capability Name=IYResolution ValueType=System.Single Value=150
24.11.2015 16:18:30 31,846,400 Result: Success
24.11.2015 16:18:30 31,846,400 Capability value is set
24.11.2015 16:18:30 31,907,840 Getting value of capability Name=Indicators Method=GetCurrent
24.11.2015 16:18:30 31,916,032 UsageMode=Get, Set, GetDefault, Reset
24.11.2015 16:18:30 31,916,032 ContainerType=OneValue
24.11.2015 16:18:30 31,916,032 ValueType=Bool CurrentValue=True
24.11.2015 16:18:30 31,924,224 Capability value is received
24.11.2015 16:18:30 31,924,224 Getting value of capability Name=IXferMech Method=GetCurrent
24.11.2015 16:18:30 31,924,224 UsageMode=Get, Set, GetDefault, Reset
24.11.2015 16:18:30 31,924,224 ContainerType=OneValue
24.11.2015 16:18:30 31,924,224 ValueType=UInt16 CurrentValue=0
24.11.2015 16:18:30 31,932,416 Capability value is received
24.11.2015 16:18:30 31,940,608 Device is enabling ShowUI=False ModalUI=True
24.11.2015 16:19:05 32,030,720 DeviceStateChanged Opened => Enabled
24.11.2015 16:19:05 35,921,920 Received request to close the device
What can possible cause this behaviour?
Thank you for your support.
Best regards,
Daniel