Hi,

I'm a new one for c++. I want to call a function in time intervals. (as an example lets say for every 100ms ). How can I do that. Please help:S
Thank you

Recommended Answers

All 4 Replies

If you get the boost libraries you can put that function in another thread and then have it wake up every XXX milliseconds or so. Don't expect very accurate timeing because that will not happen on multi-process operating systems like *nix and MS-Windows.

There are other ways too, some os dependent and some not. None of them are very nice.

in dos.h file you will find function told
delay that takes time as argument i think it will be useful for you

commented: Two steps forward, three steps back. -2

dos.h is only supported bo borland's TurboC and TurboC++ compilers, Microsoft VC q1.52C (and earlier), and maybe some very old versions of Watcom C. No other compilers has it. All those compilers are dead in the commercial world and only used by hobbiests today.

There is a sleep function in windows. For example:

Sleep(100); //will sleep for 100 ms and then wake up

You can use this to call your function every x ms.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.