Am 09.10.2008 um 16:07 schrieb Bert Freudenberg:
Am 09.10.2008 um 15:54 schrieb xyz 42:
Hello! I want to create a callback that will call my method after, say, 10 minutes. How can I do it in squeak?
[(Delay forDuration: 10 minutes) wait. self myMethod] fork
This forks off a background process, waits 10 minutes, then calls myMethod. Note that a lot of code will break when called from a background process, you will have to worry about synchronization. Especially you must not call UI code from the background (there are of course ways to allow that).
Seeing three very similar responses, here is another, safer way to do it for UI stuff. In a Morph subclass, you can say
self addAlarm: #myMethod after: 10 minutes asMilliSeconds
This will call myMethod synchronously so you do not have to worry about background processes.
- Bert -