List of connected scanners

Questions, comments and suggestions concerning VintaSoft Twain .NET SDK.

Moderator: Alex

Post Reply
felix.foerster
Posts: 2
Joined: Wed Sep 17, 2014 11:10 am

List of connected scanners

Post 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
Alex
Site Admin
Posts: 2305
Joined: Thu Jul 10, 2008 2:21 pm

Re: List of connected scanners

Post by Alex »

Hello Felix,

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

Best regards, Alexander
felix.foerster
Posts: 2
Joined: Wed Sep 17, 2014 11:10 am

Re: List of connected scanners

Post 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
Alex
Site Admin
Posts: 2305
Joined: Thu Jul 10, 2008 2:21 pm

Re: List of connected scanners

Post 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
Alex
Site Admin
Posts: 2305
Joined: Thu Jul 10, 2008 2:21 pm

Re: List of connected scanners

Post 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
Post Reply