LB Booster
« Blocking Mouse Clicks »

Welcome Guest. Please Login or Register.
Apr 1st, 2018, 04:50am



ATTENTION MEMBERS: Conforums will be closing it doors and discontinuing its service on April 15, 2018.
We apologize Conforums does not have any export functions to migrate data.
Ad-Free has been deactivated. Outstanding Ad-Free credits will be reimbursed to respective payment methods.

Thank you Conforums members.
Speed up Liberty BASIC programs by up to ten times!
Compile Liberty BASIC programs to compact, standalone executables!
Overcome many of Liberty BASIC's bugs and limitations!
LB Booster Resources
LB Booster documentation
LB Booster Home Page
LB Booster technical Wiki
Just BASIC forum
BBC BASIC Home Page
Liberty BASIC forum (the original)

« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: Blocking Mouse Clicks  (Read 490 times)
Jack Kelly
Full Member
ImageImageImage


member is offline

Avatar




Homepage PM

Gender: Male
Posts: 106
xx Re: Blocking Mouse Clicks
« Reply #3 on: Jun 11th, 2015, 7:46pm »

Thank you both for the good and simple suggestions. Rob, disabling wouldn't work in my particular program. Richard, your global flag works perfectly. I see that is is actually the SCAN that reads the unwanted mouse clicks. But how exactly does the SLEEP call help the CPU?
User IP Logged

Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 1348
xx Re: Blocking Mouse Clicks
« Reply #4 on: Jun 11th, 2015, 8:23pm »

on Jun 11th, 2015, 7:46pm, Jack Kelly wrote:
But how exactly does the SLEEP call help the CPU?

Without the Sleep you will be using 100% CPU (at least, 100% of that particular core if it's a multicore processor) for the duration of your delay; 5 seconds in that specific case. That's an awful lot of CPU usage for basically doing nothing at all!

Apart from being wasteful, excessive CPU usage will run a laptop battery down more quickly and/or cause heating which might require the cooling fan to run or the CPU clock frequency to fall.

The Sleep call tells Windows that you have nothing useful to do so it can give the CPU time to another thread or process; if nothing else needs the time the CPU will enter a low-power-consumption idle state.

An alternative approach to writing a delay routine is to use the TIMER statement, which will also keep CPU usage to a minimum:

Code:
sub delay seconds
    timer seconds*1000, [delay]
    wait
[delay]
    timer 0
end sub 

Richard.
User IP Logged

Pages: 1  Notify Send Topic Print
« Previous Topic | Next Topic »

| |

This forum powered for FREE by Conforums ©
Terms of Service | Privacy Policy | Conforums Support | Parental Controls