C ++: calling a schedule function in the future?
Using Visual C ++ with MFC. When a certain event occurs in my code, I want the function to be called after 10 seconds to perform some operation. The event handling happens in a static library that has no direct references to MFC (and I would like to keep it that way).
How do I assign a function to be called at some point in the future? Am I using a timer? How do I disable the timer (which is MFC specific) so my business code doesn't directly depend on the GUI? Or maybe something else besides a timer?
Update
Started reading about Command Pattern recently which seems promising for my situation. Description (my attention):
In object-oriented programming, a command pattern is a project pattern in which an object is used to represent and encapsulate all the information required to call a method at a later time.
source to share
Approach 1
Write a wrapper function to call the static library. Hibernate for the required duration before calling the static library.
Approach 2 Use a Win32 timer http://www.codeproject.com/Articles/1236/Timers-Tutorial#Win32Timers
You can avoid the MFC dependency in both approaches.
source to share