943,600 Members | Top Members by Rank

Ad:
  • C# Discussion Thread
  • Marked Solved
  • Views: 3080
  • C# RSS
Apr 8th, 2009
0

stop method from executing

Expand Post »
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?
Similar Threads
Featured Poster
Reputation Points: 854
Solved Threads: 127
Banned
serkan sendur is offline Offline
2,057 posts
since Jan 2008
Apr 8th, 2009
0

Re: stop method from executing

The same way you normally stop scanning bar codes?
Reputation Points: 231
Solved Threads: 12
Junior Poster
thoughtcoder is offline Offline
139 posts
since Mar 2009
Apr 8th, 2009
0

Re: stop method from executing

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.
Featured Poster
Reputation Points: 854
Solved Threads: 127
Banned
serkan sendur is offline Offline
2,057 posts
since Jan 2008
Apr 9th, 2009
0

Re: stop method from executing

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?
Team Colleague
Reputation Points: 186
Solved Threads: 147
Cookie... That's it
alc6379 is offline Offline
2,519 posts
since Dec 2003
Apr 10th, 2009
0

Re: stop method from executing

Click to Expand / Collapse  Quote originally posted by alc6379 ...
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.
Featured Poster
Reputation Points: 854
Solved Threads: 127
Banned
serkan sendur is offline Offline
2,057 posts
since Jan 2008
Apr 11th, 2009
0

Re: stop method from executing

To stop it noway else putting it on a specific thread then in some defined cases you kill this thread.
Featured Poster
Reputation Points: 480
Solved Threads: 276
Postaholic
Ramy Mahrous is offline Offline
2,189 posts
since Aug 2006

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C# Forum Timeline: ConnecionString
Next Thread in C# Forum Timeline: Performance problem with background image





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC