473,499 Members | 1,916 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to looping with Timer?

1 New Member
Dear all,
I am a student making a MS Form application in C++. I would ask a question about "Timer". Sample code which I am developing is below.

private: System::Void buttonStart_Click(System::Object^ sender, System::EventArgs^ e){
for (int i=1; i<=10; i++){
String^ strValue;
FunctionName(&strValue);
int interval=1000; // time interval of looping equal to 1s
SetTimer(timer1, interval, NULL);
do {
this->textBox->Text = strValue;
}
while(TimerFlag = 0);
TimerFlag = 0;
}

private: System::Void FunctionName(String^ *strValue){
*strValue = "Something which could change in each time of above looping";
}

private: System::Void OnTimer(int timerId){
if(timerId = 1){
TimerFlag = 1;
HWND hwnd = NULL;
KillTimer(timer1);
}
}
...

Compiling errors are
1. SetTimer doesn't take 3 arguments
2. Kill timer doesn't take 1 arguments

How should I input the arguments and how should I correctly looping with 1s interruption? Please help me!

Thank you very much in advance.

Davaa
Jul 9 '08 #1
2 2059
gpraghuram
1,275 Recognized Expert Top Contributor
If you are free to use any libraries then try to use ACE.
It has a timer also in it...

Raghu
Jul 9 '08 #2
hdanw
61 New Member
Expand|Select|Wrap|Line Numbers
  1. while(TimerFlag = 0);
This will always fail to execute as

Expand|Select|Wrap|Line Numbers
  1. TimerFlag = 0
will always be false.

Expand|Select|Wrap|Line Numbers
  1. if(timerId = 1)
This line isuseless unless you actually want to assing 1 to timerId, but the braces and the if are not neccessary.

I think you stick with the basics for now.

You need to get with your instructor and let him or her know you need some one on one time with a tutor.

Somethings are quicker when your not strugling with the slow communication of the internet.

Also, a tutor can see whether this code took you a few seconds to write or a few days, and they can imediately address the areas that you should be focusing on.

Expand|Select|Wrap|Line Numbers
  1. if( SomeValue == 1) 
Notice the second '='?
Jul 12 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

13
7429
by: Manuel Lopez | last post by:
I have a puzzling form timer problem that I didn't experience prior to Access 2003 (though I'm not sure access 2003 is to blame). Here's the situation: a computer has two access 2003 databases on...
45
7391
by: Trevor Best | last post by:
I did a test once using a looping variable, first dimmed as Integer, then as Long. I found the Integer was quicker at looping. I knew this to be true back in the 16 bit days where the CPU's (80286)...
9
7243
by: HL | last post by:
I am using VS 2005 Beta - C# Problem: The Timer fires a few milliseconds before the actual Due-Time Let's say a timer is created in the following manner: System.Threading.Timer m_timer = null;...
2
4033
by: John David Thornton | last post by:
I've got a Windows Service class, and I put a System.Threading.Timer, and I've coded it as shown below. However, when I install the service and then start it in MMC, I get a peculiar message: ...
11
1913
by: Liam.M | last post by:
Hey guys, If anyone could spare sometime to help me out, it would be very much appreciated.....what I am trying to do is automate a "Command" that sends me an Email. I have created a Query that...
12
5490
by: Gina_Marano | last post by:
I have created an array of timers (1-n). At first I just created windows form timers but I read that system timers are better for background work. The timers will just be monitoring different...
0
1530
by: Jim S | last post by:
Is looping FindWindow() ok? We have a simple little c# 2.0 app that’s sole purpose is to look for a dialog box from another app to pop up and then click it’s OK button. To do this we use a...
8
2636
by: =?Utf-8?B?RGF2ZSBCb29rZXI=?= | last post by:
I have a Timer that I set to go off once a day, but it frequently fails! In order to debug I would like to be able to check, at any moment, whether the Timer is enabled and when it will next...
16
3227
by: Peter Oliphant | last post by:
Note that although this involves SAPI, it is more a question about Timers and event handlers. I wrote a Speech Recognize handler (SAPI), and put some code in it to enable a Timer. It would not...
0
7134
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7012
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7225
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6901
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
1
4920
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4605
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3101
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1429
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
307
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.