Page 1 of 1

List of connected scanners

Posted: Wed Sep 17, 2014 11:16 am
by felix.foerster
Hey there,

we're using a licensed version of VintaSoftTwain.NET 8.3.6.1 and have problems with the list of scanners the DeviceManager provides.
Our application runs on a server and provides a list of connected scanners via DeviceManager.Devices.Count and DeviceManager.Devices.GetDevice(index).Info.ProductName.
If a scanner is getting disconnected while the server runs, the methods of the DeviceManager show the disconnected scanner nevertheless. You have to restart the whole program to refresh this devicelist.

Is it possible to refresh the devicelist of the DeviceManager to show if the scanner is connected?

Thank you in advance
Felix

Re: List of connected scanners

Posted: Wed Sep 17, 2014 11:28 am
by Alex
Hello Felix,

You can close the device manager and open it again - this actions will refresh the devices list.

Best regards, Alexander

Re: List of connected scanners

Posted: Wed Sep 17, 2014 2:30 pm
by felix.foerster
Hi Alex,

thanks for your answer. I tried closing and re-opening the device manager.
If I connect an additional scanner it is added to the list, but if I disconnect one it is shown although it isn't plugged in any longer after closing and opening the device manager.

Best regards
Felix

Re: List of connected scanners

Posted: Thu Sep 18, 2014 11:11 am
by Alex
Hi Felix,

Thank you for information. We have reproduced the problem and will try to fix it in shortest time.

Best regards, Alexander

Re: List of connected scanners

Posted: Mon Sep 22, 2014 3:32 pm
by Alex
Hello Felix,

In version 9.0.3.1 we have improved the algorithm that loads TWAIN device manager and now you can get refreshed device list as follows:

Code: Select all

int oldDeviceCount = 0;
int newDeviceCount = 0;

// create the device manager
using (DeviceManager deviceManager = new DeviceManager())
{
    // open the device manager
    deviceManager.Open();

    // get device count
    oldDeviceCount = deviceManager.Devices.Count;

    // close the device manager
    deviceManager.Close();
}

Console.WriteLine("Please detach one or several USB TWAIN devices.");
Console.WriteLine("Press any key when done.");
Console.ReadKey();

// create new device manager
using (DeviceManager deviceManager = new DeviceManager())
{
    // open the device manager
    deviceManager.Open();

    // get device count
    newDeviceCount = deviceManager.Devices.Count;

    // close the device manager
    deviceManager.Close();
}

if (oldDeviceCount <= newDeviceCount)
    throw new ApplicationException("Device list is not refreshed.");
Best regards, Alexander