VintaSoft Twain .NET SDK Discussions

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

Board index < VintaSoft Twain < VintaSoft Twain .NET SDK Discussions

We are migrating to new forums engine, no new registration or posting currently available. TIA for your patience.

List of connected scanners



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


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


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


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


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:
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


Page 1 from 1: 1