Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
5 years, 6 months ago. This question has been closed. Reason: Too broad - no single answer
How to call a function using EventQueue, but then also be able to cancel it?
I haven't used EventQueue before in any language, so this is new to me and the documentation is inefficient for me to be able to know if it is useful for what I want to do.
I would like to call a function every set amount of time, but then be able to also cancel that function.
So I would like to do something like this:
queue.call_every(period, myOwnFunction(z,x) ); //call this function every period. queue.dispatch(); //To make it run I would need this?
if (exitEvt == 1) { //if certain variable in main() program is set, the event should terminate at next available opportunity queue.break_dispatch(); //this should kill off my event, or should cancel() be used here instead..? }
Would this approach work? How do I 'call_every' a function?
I would also preferably want to then change the function the queue is calling after stopping the dispatch, so instead of myOwnFunction calling with parameters z and x, it would now be set up to call with parameters a and b, and so I can then dispatch it again after making that change.