Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Using Ao_timer for a better sleep (See related posts)

A few of my old examples include 'unsafe' use of e32.ao_sleep().
The problem is that the sleep can't be interrupted.
I often use a convenient loop like this
while running:
  // do something
  e32.ao_sleep(1)  # sleep a sec


Now in pys60 1.3.1, it's better to use e32.Ao_timer
timer = e32.Ao_timer()
while running:
  // do something
  timer.after(1)   # sleep a sec

I can then interupt the sleep with
timer.cancel()

in other part of the program if I need to continue the loop.

For example, I can end the application without waiting for
the last second.

You need to create an account or log in to post comments to this site.


Click here to browse all 5059 code snippets

Related Posts