Thread: TrackwheelClick
View Single Post
Old 09-03-2004, 01:14 PM   #10
Mark Rejhon
Retired BBF Moderator
 
Mark Rejhon's Avatar
 
Join Date: Aug 2004
Location: Ottawa, Ontario, Canada
Model: Bold
Carrier: Rogers
Posts: 4,870
Default

eradis, that's another good solution. Basically the button click triggers the code in another thread, and the button click event exits immediately while the other thread continues to process. The other thread sets a flag at the beginning and clears the flag at the end of the processing. The original button click event can check this flag and ignore subsequent clicks if the other thread is still processing.

Another method of this multithreaded way if there's a continuous loop in the other thread monitoring a flag, is that the button click event sets the flag, and the other thread only clears the flag when all the processing is done and that new button clicks are okay.

Some people need to avoid multithreaded programming for certain reasons though, or when it's too difficult (i.e. potentially makes software unstable). In these cases, it's better to err on the side of stability.
__________________
Thanks,
Mark Rejhon
Author of XMPP extension XEP-0301:
www.xmpp.org/extensions/xep-0301.html - specification
www.realjabber.org - open source
Offline