Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Callbacks and Timers » How to properly set a timer
Re: How to properly set a timer [message #49559 is a reply to message #49557] Thu, 01 March 2018 15:12 Go to previous messageGo to previous message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
koldo wrote on Thu, 01 March 2018 10:19
Hello all

This question is strangely derived from this post.

I wanted to ask you how to set properly a timer. Three options:


Generally, you have to avoid situation where callback is invoked after target instance is destroyed.

Quote:

1. Inside a class derived from Ctrl
SetTimeCallback(time, THISBACK(callbackFunction));


In client code, use TimerCallback. TimerCallback destructor removes the callback from the timer queue if necessarry.

You can use SetTimeCallback directly, but then you have to rember id and remove in destructor.


Quote:

2. In a GUI program, in a class not derived from Ctrl


Use SetTimeCallback directly, but remember to remove callback from the queue as necessary.

Quote:

3. In a console program


You cannot. It is CtrlCore feature...

Mirek

[Updated on: Thu, 01 March 2018 15:12]

Report message to a moderator

 
Read Message
Read Message
Read Message
Read Message
Previous Topic: [REQUEST]: Allow callback() template to work also with non-void and non-bool return types.
Next Topic: How to set a TimeCallback
Goto Forum:
  


Current Time: Sun Apr 28 12:33:34 CEST 2024

Total time taken to generate the page: 0.05660 seconds