| | |
Timer event doesn't get triggered
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Jun 2005
Posts: 69
Reputation:
Solved Threads: 0
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.
•
•
Join Date: Jun 2005
Posts: 69
Reputation:
Solved Threads: 0
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);
}
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);
}
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?
and inside the TimerEventHandler
Check it out.
//
// 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.
![]() |
Similar Threads
- Text Timer (Visual Basic 4 / 5 / 6)
- Timer Question (Visual Basic 4 / 5 / 6)
Other Threads in the C++ Forum
- Previous Thread: Variable Movie Speed in C++ Builder
- Next Thread: Compiling Problems
| Thread Tools | Search this Thread |
api application array arrays based beginner binary c++ c/c++ calculator char char* class classes code compile compiler console conversion count delete deploy desktop directshow dll download dynamic dynamiccharacterarray encryption error file forms fstream function functions game givemetehcodez google graph gui homeworkhelp iamthwee ifstream input int java lib library linkedlist linker list loop looping loops map math matrix memory newbie news number numbertoword output pointer problem program programming project python random read recursion recursive reference return rpg simple sorting string strings studio temperature template templates test text text-file tree unix url variable vector video visual visualstudio win32 windows winsock wordfrequency wxwidgets






