Home › Forums › TWAIN Classic › detect twain is using from another application ?
- This topic has 3 replies, 2 voices, and was last updated 10 years, 2 months ago by spike.
- AuthorPosts
I have a question using the twain driver
At the customer, more than one twain application is installed.
I have a problem at the following scenario :
1- The first application (other application-does not matter) opens the twain data source and shows the driver graphical user interface
2- At this time, a scan request is sent from network to our application(second application). We are using the TwainDSM. There is no problem until we sent MSG_OPENDS message,
But when we sent MSG_OPENDS message, our application thread hangs and wait forever.My question is :
– How to solve this hanging problem ?
– Is it possible to understand that the twain driver is currently used by an another application and is not suitable for sending the MSG_OPENDS message ?1- The first application (other application-does not matter) opens the twain data source and shows the driver graphical user interface
2- At this time, a scan request is sent from network to our application(second application). We are using the TwainDSM. There is no problem until we sent MSG_OPENDS message,
But when we sent MSG_OPENDS message, our application thread hangs and wait forever.
My question is :
– How to solve this hanging problem ?
– Is it possible to understand that the twain driver is currently used by an another application and is not suitable for sending the MSG_OPENDS message ?There is no TWAIN mechanism for asking if a driver or device is busy, the TWAIN device driver is responsible for detecting this situation and responding appropriately.
1. Check that your application is correctly checking the return code from the MSG_OPENDS, so if the driver is failing the 2nd open, your code would handle that correctly. I would expect a properly coded driver to return TWRC_FAILURE, and then report a Condition Code of TWCC_MAXCONNECTIONS (“The data source cannot support any more connections to this device”).
2. If your application is correctly coded and the driver is hanging inside the MSG_OPENDS call, then this is a driver problem, and you should discuss this with the scanner vendor.
Hi Spike,
I realized that when I send MSG_OPENDS to TWAIN driver,the driver will throw a pop-up(message:twain is in use). But I am using windows service
so i couldn’t see the popup and application hangs. I don’t want to enable the “desktop interaction” property on windows service.Is there another way to overcome this problem ?
Thank You
@spike wrote:
1- The first application (other application-does not matter) opens the twain data source and shows the driver graphical user interface
2- At this time, a scan request is sent from network to our application(second application). We are using the TwainDSM. There is no problem until we sent MSG_OPENDS message,
But when we sent MSG_OPENDS message, our application thread hangs and wait forever.
My question is :
– How to solve this hanging problem ?
– Is it possible to understand that the twain driver is currently used by an another application and is not suitable for sending the MSG_OPENDS message ?There is no TWAIN mechanism for asking if a driver or device is busy, the TWAIN device driver is responsible for detecting this situation and responding appropriately.
1. Check that your application is correctly checking the return code from the MSG_OPENDS, so if the driver is failing the 2nd open, your code would handle that correctly. I would expect a properly coded driver to return TWRC_FAILURE, and then report a Condition Code of TWCC_MAXCONNECTIONS (“The data source cannot support any more connections to this device”).
2. If your application is correctly coded and the driver is hanging inside the MSG_OPENDS call, then this is a driver problem, and you should discuss this with the scanner vendor.
Hi yns.emre
The answer in a general way remains “no”. TWAIN drivers often display a modal dialog when they encounter certain conditions. In general this is not prohibited by the TWAIN standard, so it is common but (like every TWAIN thing) the details vary from driver to driver. Even when the application disables the scanner User Interface (with ShowUI=FALSE), there is a strong chance the driver still creates its main window, just keeping it hidden.
So I wonder: If you don’t allow the first TWAIN application to run, does your service work, when it does not have to ‘share’ the scanner?
I am concerned because TWAIN generally does not work in a service, especially if desktop interaction is disabled: TWAIN drivers assume that they can create windows and interact with the user, and there is no way to stop them from doing this.
Well 8) it’s Windows, so nothing is impossible – but you’d have to hook/intercept calls to the common Windows API functions like DialogBox. At least. Probably very messy.
What I’ve seen people do (e.g. EMC Captiva’s Web Scanning Toolkit) is this: They run a service, and when the service is asked to do scanning, it launches an .exe as a separate process. I guess they launch the scan process as belonging to the user who submitted the request to the service?
- AuthorPosts