hi guys, i have a pocket pc application where i scan some barcodes, i want to stop scanning when i open a new form.
do you have any ideas how to stop it?

The same way you normally stop scanning bar codes?

The same way you normally stop scanning bar codes?

actually my problem was device specific, the scantimeout can be set to 10 seconds which means it is going to scan continuously for 10 seconds, i wanted to stop it but i couldnt because it only stops when the timout is reached or the key is released or something is scanned. i work on handheld dolphin 7900 with sdk 111, it appearantly does not have such method to interrupt scanning.

Could you maybe set a scan timeout for a shorter period of time, set that running on a thread, and have that thread check for some type of stop "signal" before scanning again? I think a Singleton pattern or something could work for this:

instantiate a "ScanMonitor" object that has a "Cancel" boolean property. (This can go to your scan() method)

Then, you could have another thread change ScanMonitor's Cancel property to "true" when you need to stop scanning.

set a while(true) loop to keep looping on that scan method with a short scan time, but before you scan, check if ScanMonitor.Cancel == true.

Does that make sense?

Could you maybe set a scan timeout for a shorter period of time, set that running on a thread, and have that thread check for some type of stop "signal" before scanning again? I think a Singleton pattern or something could work for this:

instantiate a "ScanMonitor" object that has a "Cancel" boolean property. (This can go to your scan() method)

Then, you could have another thread change ScanMonitor's Cancel property to "true" when you need to stop scanning.

set a while(true) loop to keep looping on that scan method with a short scan time, but before you scan, check if ScanMonitor.Cancel == true.

Does that make sense?

Actually it doesnt bother to have the scanning on after moving to another form because its scan handle method checks if any handler is registered to that event, since there is none, it does not do anything on the next form, so i got around the problem.
i think i could use some multithreading functionality like abort or interrupt thread, but anyway simpler is better.
thanks.

To stop it noway else putting it on a specific thread then in some defined cases you kill this thread.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.