473,320 Members | 1,867 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

How to stop a timer at a given time in C#?

how to stop a timer at a given time? say 10mins?
Feb 23 '12 #1
2 1737
GaryTexmo
1,501 Expert 1GB
Get the value of DateTime.Now before you start it and store it somewhere like a variable called startTime. Then check to see if (DateTime.Now - startTime).TotalMinutes is greater than 10.

(NOTE: Subtracting, or adding, two DateTime values results in a TimeSpan object)
Feb 23 '12 #2
GaryTexmo
1,501 Expert 1GB
I should also mention, if your timer is ticking every X seconds/minutes but you want to turn it off after exactly 10, you could always use a second timer. Create it, set the interval to whatever your timeout is, then turn both timers off when the second timer ticks.

Whatever works best for you.
Feb 23 '12 #3

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

Similar topics

3
by: CrystalDBA | last post by:
I am using SQL Server 2000. I need to query my database for all the contracts that came in during a certain time frame (user is prompted for reportingperiodid). Table - Periods Fields -...
1
by: Lei Guangfu | last post by:
Hi, I have a program need to check the value of a application available, and then decide whether to execute codes followed. In order to achieve this purpose, I use DO WHILE loop to judge the...
1
by: Lei Guangfu | last post by:
Hi, I have a program need to delay for a given time, I use DO WHILE loop to achieve this goal, but this method consumes too much CPU resource. So I want to find a way to pause a process for a...
7
by: J e r | last post by:
I'm a novice using VB .NET . I'm trying to use 2 files to read a line write the line and get the run time error "..exception of type 'System.IO.IOException.....additional information: File...
1
by: dponce | last post by:
Best regards to all, I am new to this form and site, not to mention I am a beginning MS Access developer. This software came install on my laptop and seems to be pretty cool programming software....
2
by: Mathias Weyel | last post by:
Hi there, I have time-of-day spans presented as strings and want to check, if, at a given time, I am within such a time span. Example: Timespan-string is given as follows: "09:00 , 16:00" A...
2
by: Elliot | last post by:
My program use a timer to 'refresh' a method "a" every several seconds, private void a(object sender, EventArgs eArgs) { Timer T1 = new Timer(); T1.Interval = 100000; T1.Start(); T1.Tick +=...
1
by: sasasasa | last post by:
How can I loop through each date in a given time period so that I can add those dates as a column name in a table. I want to create datatable with the person's name and hours he worked in a given...
3
by: ashimasingh | last post by:
hello , i need a help regarding python programming: basically i need to find out times between the start and the stop time. Here is what i have tried--- s = raw_input('enter first time...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.