Multitasking using events

BlitzMax Forums/BlitzMax Programming/Multitasking using events

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

Hmm, ok. Thanks for the feedback guys.

Here are some follow-up questions, then.

1. Do hooks get called when you use PollEvent() as well?

2. In my main loop if I use PeekEvent() to look at the queue and if there is no event I do some processing, but when there is an event I do PollEvent(), do the hooks then get called and executed when the PollEvent() occurs? Does PeekEvent trigger the hooks? Do the hooks trigger when the event arrives in the queue regardless of whether we look at it?

3. Do you HAVE to have a place in your program where you call WaitEvent(), WaitSystem() or PollEvent(), in order for any hooks to ever be run at all? Otherwise the hooks are never run because control isn't handed over to the system?

4. Dreamora's comment on point 5 - So even if the timer is pretty accurate at generating events, the execution of the TIMERTICK hook is only as accurate as how often I call WaitEvent() to trigger the check?

5. Dreamora's comment on point 7 - But a hook can call any other function anywhere in the program, plus access global variables, so only locally-made variables are limited to the scope of the hook function, right?

6. Dreamora's comment on point 8 - That's presuming that you can't `suspend` whatever is being executed in order to return and resume later. With a regular BlitzMax program you can't, but with scripts or some other interpretation engine you can.

7. Okay so as I understand it, the hook function is not given to the o/s as something it should jump to, rather when you call WaitSystem()/WaitEvent()/PollEvent() BlitzMax goes through each event in the queue and calls the hook function for each one?

8. I understand that the hook would not be pre-empted by anything in the main program loop. But if your main program is using PeekEvent() so that it only runs the hooks when there are some, that's sort of a way of `cooperatively multitasking` at least, even though it's not pre-emptive?

Thanks for your time.