D
Dave Boland
I read a lot of discussion about callback functions as used in C (as in
qsort for example). I'm comfortable with this as it is really a
function pointer. What I'm not totally clear about is how (or if) a
callback differs from an event such as GUI's use. One of the things I
found about events, at least in a VB6 project I did, is that an event
can be broadcast to all objects and they can use it if desired (code
only and GUI objects). Each object has to have a receive function for
that event though.
The only way I can see to do event broadcasting with a callback is to
have a special callback that in turn calls a list of receiver functions
that would be in each module. For example, a timer that broadcasts a
time tick every second would call a function (for example)
Timer_1min(void) that in turn would call functions in all of the modules
that need to know the time. I've also thought about a message que, but
that is begining to sound like too musch work. Is there a better way?
Thanks for any helpful information.
Dave,
qsort for example). I'm comfortable with this as it is really a
function pointer. What I'm not totally clear about is how (or if) a
callback differs from an event such as GUI's use. One of the things I
found about events, at least in a VB6 project I did, is that an event
can be broadcast to all objects and they can use it if desired (code
only and GUI objects). Each object has to have a receive function for
that event though.
The only way I can see to do event broadcasting with a callback is to
have a special callback that in turn calls a list of receiver functions
that would be in each module. For example, a timer that broadcasts a
time tick every second would call a function (for example)
Timer_1min(void) that in turn would call functions in all of the modules
that need to know the time. I've also thought about a message que, but
that is begining to sound like too musch work. Is there a better way?
Thanks for any helpful information.
Dave,