Home > Archive > MSDN > June 2006 > SetTimer function
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
|
|
|
| Hi,
How to call a function in every 1 second time interval.
I tried using SetTimer with CALLBACK function its not working. In this case
Im not using any GUI functions (dialog or frame) for my application.
Any help would be great.
thanks,
--
Student
-thiru
| |
| lallous 2006-06-28, 3:56 am |
| Hello
I don't think this is the appropriate newsgroup, you could have tried
microsoft.public.win32.programmer.kernel or .vc.mfc
To achieve what you're asking with little code you can use threads:
Pseudo code:
bool g_quit = false;
int __stdcall threadproc(LPVOID ctx)
{
while (g_quit == false)
{
// Sleep 1 second
::Sleep(1000);
// Do something after the wait....
}
}
int main()
{
// create something like a timer
HANDLE hThread = ::CreateThread(...., threadproc, ....);
// do something .... (while thread is executing) ....
// ............
// when you want to quit the thread:
//1. g_quit = true
//2. waitforsingleobject(hThread, ...);
//3. closehandle(hthead);
}
--
Elias
"Thiru" <Thiru@discussions.microsoft.com> wrote in message
news:0E878F59-C5B4-436D-ACA0-D5C683A8262A@microsoft.com...
> Hi,
> How to call a function in every 1 second time interval.
> I tried using SetTimer with CALLBACK function its not working. In this
> case
> Im not using any GUI functions (dialog or frame) for my application.
> Any help would be great.
> thanks,
> --
> Student
> -thiru
|
|
|
|
|