How to execute a function called many times, only once !

Posted by Roesone on Stack Overflow See other posts from Stack Overflow or by Roesone
Published on 2010-04-01T13:04:13Z Indexed on 2010/04/01 13:43 UTC
Read the original article Hit count: 224

Filed under:
|
|

Hello,

is there a way to execute a function that is called thousand of times only once ? I have a function that adds items in a container of sort, and there is code in there, that updates lists and other windows (GUI staff). So, if i have to add a million items (the number of which is impossible to tell, anyone could call the function from anywhere), the GUI update mechanism will be called as many as times... Is there a way to tell appart continuous function execution (and ignore it) from discontinuous ? Is there a safe way to execute the update mechanism only the last time the add-item function is called, within a time interval ?

Thank you.

© Stack Overflow or respective owner

Related posts about c++

Related posts about function