[REBOL] Re: Window using forever loop
From: anton::wilddsl::net::au at: 5-Dec-2006 19:40
Hi Thorsten,
If you can divide your process up into chunks with a
short time interval, then you can use the technique below:
Anton.
window: layout [
pic: image (make image! 100x100)
btn "abort" [abort?: true]
]
max-n: pic/image/size/x * pic/image/size/y
do-some-work: func [n][
print ["do some work" now/time/precise]
loop 279 [
poke pic/image n random white
n: n + 1
if n > max-n [break]
]
show window
n
]
n: 1 ; work position
abort?: none
forever [
if n < max-n [ ; still work to do ?
if not find system/view/screen-face/pane window [ ; window not shown
already ?
view/new window ; open the window without WAITing
]
n: do-some-work n
]
print "handle events"
wait 0.2 ; <- this waits for window events and also for a 0.2 second
timeout
; WAIT waits for window events by default because system/view/event-port is
found
; by default in system/ports/wait-list
if abort? [break]
]