Creating Thread Using A Timer

Posts 1–6 of 6 · Page 1 of 1
Creating Thread Using A Timer
can anyone give me
Timer With create Thread in one line please
[highlight=c++]void SampleFunction() {
int x = 300;
while(x > 0)
{
cout << x << endl;
x-=1;
}
}
void main()
{
int SecondsToWait = 5;
Sleep(SecondsToWait * 1000);
CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE) SampleFunction, NULL, 0, NULL);
}[/highlight]

LOL @Nico ... Do you think he will do it ?
@Hassan
I Mean Thread Made By Timer
Timer(SampleFunction) do u understand me ??
Quote Originally Posted by lindRobe View Post
@Hassan
I Mean Thread Made By Timer
Timer(SampleFunction) do u understand me ??
Code:
void Timer(LPTHREAD_START_ROUTINE func, int SecondsToWait)
{
    Sleep(SecondsToWait * 1000);
    CreateThread(NULL, 0, func, NULL, 0, NULL);
}
I think he wants to measure execution time of a function:

Code:
DWORD old = timeGetTime();

// exec function

cout<<"execution time:"<<timeGetTime()-old;
Posts 1–6 of 6 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Talk with us