473,624 Members | 2,543 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

C# Simple Counter

2 New Member
i'm very new to C#. i have homework for a class im taking that i just cant figure out. we're working with events & delegates. the particular event is a clock, and when a minute elapses, i have to run an event that prints "a minute has elapsed". i have this working, however, it prints the statement when the minute changes (1:03:53 goes to 1:04:00), not when an actual 60 secs have elapsed (1:03:53 goes to 1:04:53). the teacher says we could use a "simple counter" to do it the "quick and dirty way", but i have no clue where to start. i tried using a Clock, starting it, then calling the event when the seconds reached 60, then reset the clock back to 0. but could not get it to work. the solution is probably much more simple than that anyway. any help/direction would be greatly appreciated.

here's the current code im using to raise the event:
Expand|Select|Wrap|Line Numbers
  1. // if datetime.minute != theClock.minute
  2. if (dt.Minute != minute)
  3.                 {
  4.                     TimeInfoEventArgs timeInformation =
  5.                         new TimeInfoEventArgs(dt.Hour, dt.Minute, dt.Second);
  6.             OnMinuteElapsed(timeInformation);
  7.  
  8.                 }
thanks in advance
Apr 4 '07 #1
1 1613
ruckus
8 New Member
If you're using .Net, you should have access to the "timer" object. This will time in milliseconds, but you can simply make the computer react after a minute of milliseconds. Unless you specifically want to use the clock, this will work.
Apr 5 '07 #2

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

Similar topics

16
10641
by: Paul Rubin | last post by:
I'd like to have a function (or other callable object) that returns 0, 1, 2, etc. on repeated calls. That is: print f() # prints 0 print f() # prints 1 print f() # prints 2 # etc. There should never be any possibility of any number getting returned twice, or getting skipped over, even if f is being called from
6
3270
by: Tom | last post by:
We have a VERY simple .NET C# Form Application, that has about a 23MB Memory Footprint. It starts a window runs a process and does a regular expression. I have done a GC.Collect to make sure that, no memory is lying around. GC reports only 84k of allocations. Starting 5-10 of this apps is going to start taking a considerable amount of memory. Is there a way to reduce this? Tom
2
2187
by: jagivens | last post by:
Hi, I have two identical programs that encrypt characters. One is written in C++, and it works, but the other one is written in C, and it does not work. I have copied the code below. There is a problem somewhere in the while loop in the C program. It goes through the code one full time (and updates the counter) before asking for user input - thus it updates the counter twice for every one input. Since I'm not so familiar with C,...
32
5093
by: someone else | last post by:
hi all I'm a newbie to this group. my apologies if I break any rules. I've wrote a simple program to find the first 1,000,000 primes, and to find all primes within any range (up to 200 * 10^12) it's pretty efficient, it took 15 minutes to compute the first 1,000,000 primes.
6
4428
by: | last post by:
Why is my progress bar displayed only after it's reached 100%? <html> <style type="text/css"> #bar{ width: 10px; height: 14px; color: white; font-size: 12px; overflow: hidden;
30
3508
by: galiorenye | last post by:
Hi, Given this code: A** ppA = new A*; A *pA = NULL; for(int i = 0; i < 10; ++i) { pA = ppA; //do something with pA
1
1561
by: rjoseph | last post by:
HI Guys I have a simple check box form (using GET as the method) with a list of 10 different UK counties. I have validated the form so that users have to select no more and no less than 5 UK counties. The validation works fine. However, when the form is posted to my next page (myresults.asp), I need the values of the options to output the following in my url, no matter what UK counties they choose or what order they select them in: I...
11
1561
by: James R. Davis | last post by:
Yes, a newbie here. Though I am making progress, slowly, I am also getting more and more confused. With ASP, when I wanted to do something as trivial as updating a visitor counter, I connected to a database, executed a SQL command to read the current value of a field into a recordset, updated the value by adding 1 and writing the field back to the table, closed and got rid of the connection and recordset. I had no concerns about how...
11
1477
by: tony19760619 | last post by:
To make this work on a single page you will need to create/modify 4 files. So here goes... Create a file called counter.php and put following code in it: <?php //Counter $count_my_page = ("hitcounter.txt"); $hits = file($count_my_page); $hits ++;
9
2245
by: Pygmalion | last post by:
I have found dozen of useful PHP counters on the web. However, nobody is working for my web pages, since administrator does not want to enable the possibility that PHP could be called from HTML. (i.e. "Addhandler application/x-httpd-php .html .php" in .htaccess). He says it is a security problem. Is it possible to make a PHP counter WITHOUT using echo command? Thanks for your suggestions,
0
8249
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
8685
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
8633
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...
1
8348
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7176
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...
1
6112
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5570
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();...
1
1797
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1493
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.