473,732 Members | 2,171 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_Cli ck(System::Obje ct^ sender, System::EventAr gs^ e){
for (int i=1; i<=10; i++){
String^ strValue;
FunctionName(&s trValue);
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(St ring^ *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(timer 1);
}
}
...

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 2080
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
7493
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 it, a frontend and a backend. Case 1: If vba code on the frontend updates many rows (360,000) on the backend, a form's timer event (from the frontend) will stop firing until the user gives the form focus. (Note that the update itself always...
45
7462
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) word size was 16 bits same as an integer. Now with a 32 bit CPU I would have expected the long to be faster as it's the same size as the CPU's word size so wouldn't need sawing in half like a magician's assistant to calculate on like an...
9
7285
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; Let's declare a constant Int32 m_TimePeriod = 10000;
2
4065
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: The MyService service on Local Computer started and then stopped. Some services stop automatically if they ahve no work to do, for example, the Perforamnce Logs and Alert service. I tried switching to a System.Threading.Timer and that didn't work...
11
1935
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 grabs all the records I am after...now all I need to do is get some code that will allow me loop through each of these records shown by the query and pass certain fields from these records into the Body of my email command...which then emails...
12
5526
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 directories and updating a database. No interaction with the GUI. Problem is that the system timers do not have a tag property so I can tie in an object. example (old way):
0
1554
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 form with a timer control and some unmanaged code. The app works perfectly in test but I’m concerned about long term problems/leaks caused by frequent FindWindow calls (10 per second)? Although the popups might only occur 50-100 times a day,...
8
2663
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 Elapse. Is there any way -- whether in my code, or in the O/S -- to determine when a Timer is scheduled to Elapse?
16
3255
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 do it. If I bring this same code outside this event handler, it works just fine. Is this normal?
0
8946
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8774
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9447
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9307
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9181
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8186
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6031
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4550
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3261
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 we have to send another system

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.