I'm working on a Google Chrome Twain Plugin and actually it's is almost done. The only major problem remains: the plugin does not work under Windows XP. And this is not what is desired.
The plugin uses Chrome Native Messaging to establish communications between Chrome and separate scanning process, and TwainDotNet to interface with TWAIN.
Unfortunately, nothing can prevent TWAIN drivers from sending any text to stdout/stderr, so I was forced to use a two-stage solution: the first process of the native messaging host communicates with Chrome via stdin/stdout, and the second process communicates with the first via anonymous pipes and really does the job (i.e. process messages and interfaces with TWAIN).
Somehow the pipes of the second process become a problem to TWAIN. After some experimenting, I found that if I do not create any pipe in the second process, or if I create the pipes but do not use them - i.e. I do not read from or write to the pipes, everything goes okay. But if there was a single read or write on the pipes, any operation with TWAIN hangs like as if there was no message loop running in the thread.
Thus, I think that working with pipes, I mean performing read and write operations on the pipes, somehow breaks message loop required for TWAIN to work properly.
I am a novice to Windows message processing, so
- I don't have a complete understanding what's going on there in the application when I use anonymous pipes, and
- How using pipes can interfere with TWAIN, and
- Why the problem appears under Windows XP only.
The only idea I have is that anonymous pipes asynchronous IO is implemented through windows messages. So, I will appreciate info and/or suggestions that help to solve this problem.
The plugin sources can be found in my GitHub repository (solution TwainScan): https://github.com/ballamuth/Chrome4Net/tree/master/examples