[REBOL] Re: Tracking the Inactivity
From: sunandadh:aol at: 20-Jan-2003 12:57
Phillipe:
> My solution is to track the inactivity of the user. Is there a way to make
> it, without using too much of resources ?
A method that might work with View:
-- Have a single global variable, initialised to 0
-- First thing any action facet does is add 1 to it
-- Last thing any action facet does is subtract one from it.
So forgetting serialisation problems and other issues, if the variable is
zero, nothing else is going on.
-- Have another action facet that runs in a wait loop checking this variable
and doing stuff while it is zero.
A sort of working sketch is below. But you have some issues to resolve:
-- make the "background" process run automatically, and just once (right now
you have to click it to start, and could run it more than once);
-- I'm not sure view really supports this sort of multi-tasking. Do a LOT of
stress testing before thinking of going live with something like this.
hth
Sunanda.
rebol []
unview/all
activity-count: 0
view layout [
button "thing 1" [
activity-count: activity-count + 1
loop 50 [prin "/\" wait 0.1] print ""
activity-count: activity-count - 1
]
button "thing 2" [
activity-count: activity-count + 1
loop 50 [prin ". " wait 0.1] print ""
activity-count: activity-count - 1
]
button "Background" [
nn: 0
forever [
wait 0.25
if activity-count = 0 [
loop 10 [
if activity-count <> 0 [break]
nn: nn + 1 print ["Idle time -- " nn]
wait .05
] ;;loop
] ;; forever
] ;; action
] ;; layout
]