Timer event doesn't get triggered

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Jun 2005
Posts: 69
Reputation: DotNetUser is an unknown quantity at this point 
Solved Threads: 0
DotNetUser DotNetUser is offline Offline
Junior Poster in Training

Timer event doesn't get triggered

 
0
  #1
Nov 15th, 2005
I have created three timers(5sec,5sec, and 10sec) for my Windows gui. When the timer event is triggered, it displays an Timeout error to a textbox. For some reason, the timers doesn't trigger in some procedures but does in others. I don't believe any process is holding up the code to disallow the timers from triggering. What can I do to debug the problem? Thanks.
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 1,496
Reputation: WolfPack has a spectacular aura about WolfPack has a spectacular aura about WolfPack has a spectacular aura about 
Solved Threads: 104
Moderator
WolfPack's Avatar
WolfPack WolfPack is offline Offline
Mentally Challenged Mod.

Re: Timer event doesn't get triggered

 
0
  #2
Nov 15th, 2005
Probably you missed some steps in setting up the timer. Give us the steps you carried out upto now. Oh and tell us if it is a MFC or Win32 Application.
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 69
Reputation: DotNetUser is an unknown quantity at this point 
Solved Threads: 0
DotNetUser DotNetUser is offline Offline
Junior Poster in Training

Re: Timer event doesn't get triggered

 
0
  #3
Nov 15th, 2005
The code is written in VC++ .NET. In my procedures, I call
CmdAckTimer->Start(); // Start timer
CmdAckTimer->Stop(); // Stop timer

static System::Windows::Forms::Timer * CmdAckTimer;

//
// CmdAckTimer
//
this->CmdAckTimer->Interval = 5000; // 5 sec
this->CmdAckTimer->Tick += new System::EventHandler(this, CmdAckTimer_Tick);


void Test::CmdAckTimer_Tick(System::Object * sender, System::EventArgs * e)
{
CmdAckTimer->Stop();
txtStats->Text=String::Concat (S"CmdAckTimer->Stop", S"\r\n",txtStats->Text);
txtStats->Text=String::Concat (S"Error: Cmd Ack Timer timed out ", DateTime::Now.ToLongTimeString(),S"\r\n",txtStats->Text);
}
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 1,496
Reputation: WolfPack has a spectacular aura about WolfPack has a spectacular aura about WolfPack has a spectacular aura about 
Solved Threads: 104
Moderator
WolfPack's Avatar
WolfPack WolfPack is offline Offline
Mentally Challenged Mod.

Re: Timer event doesn't get triggered

 
0
  #4
Nov 15th, 2005
I dont know much on Windows Forms Applications, but at first glance everything looks okay to me. But where do you call the CmdAckTimer->Start() method? Dont you have to call it here?

//
// CmdAckTimer
//
this->CmdAckTimer->Interval = 5000; // 5 sec
this->CmdAckTimer->Tick += new System::EventHandler(this, CmdAckTimer_Tick);
this->CmdAckTimer->Start();

and inside the TimerEventHandler
void Test::CmdAckTimer_Tick(System::Object * sender, System::EventArgs * e)
{
CmdAckTimer->Stop();
txtStats->Text=String::Concat (S"CmdAckTimer->Stop", S"\r\n",txtStats->Text);
txtStats->Text=String::Concat (S"Error: Cmd Ack Timer timed out ", DateTime::Now.ToLongTimeString(),S"\r\n",txtStats->Text);
CmdAckTimer->Enabled = true;
}

Check it out.
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 69
Reputation: DotNetUser is an unknown quantity at this point 
Solved Threads: 0
DotNetUser DotNetUser is offline Offline
Junior Poster in Training

Re: Timer event doesn't get triggered

 
0
  #5
Nov 16th, 2005
I make the Start() call in my Button click event. One thing I noticed was that the timer works in an event, but not in a static function.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C++ Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC