in reply to can I get a callback when I call a function
If there's a reason you can't use that, another common technique is to write your own runloop - but that's probably much more effort.