Overview
Features
Download
Documentation
Community
Add-Ons & Services

problem about TimerTask

Please post support and help requests here.
chmzh88
Posts: 3
Joined: 01 Sep 2012, 08:25

problem about TimerTask

Postby chmzh88 » 01 Sep 2012, 08:30

Hi all,
I got a problem about TimerTask,it can't work,Here is my code:
class TimerTest1 : public TimerTask{
void run(){
cout<<"test timer"<<endl;
}
};
Timer timer;
AutoPtr<TimerTest1> t;
timer.schedule(t, 10, 1000);
I can't found the problem about it,any one can help me,thank's

guenter
Posts: 1183
Joined: 11 Jul 2006, 16:27
Location: Austria

Re: problem about TimerTask

Postby guenter » 01 Sep 2012, 16:54

You may want to actually create your TimerTest object:

Code: Select all

AutoPtr<TimerTest1> t = new TimerTest1;

chmzh88
Posts: 3
Joined: 01 Sep 2012, 08:25

Re: problem about TimerTask

Postby chmzh88 » 02 Sep 2012, 14:28

int main(int argc, char** argv)
{
Timer timer;
AutoPtr<TimerTest1> t = new TimerTest1;
timer.schedule(t, 10, 10);
return 0;
}

it don't work

guenter
Posts: 1183
Joined: 11 Jul 2006, 16:27
Location: Austria

Re: problem about TimerTask

Postby guenter » 02 Sep 2012, 15:49

Well, your program will finish before the timer even gets a chance to start. Come on ...

chmzh88
Posts: 3
Joined: 01 Sep 2012, 08:25

Re: problem about TimerTask

Postby chmzh88 » 02 Sep 2012, 16:57

yes i do it,thank's


Return to “Support”

Who is online

Users browsing this forum: No registered users and 1 guest

cron