473,387 Members | 3,033 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,387 software developers and data experts.

Timer Control - No Longer Asynchronous?

Hi There!

I'm using Timer control to record how long my application perform certain
tasks.

However, apparently Timer control is not doing its' job (i.e. Not firing
Tick event) while my application is busy. So even if my application took 2
mins, the label that is used to show the number of seconds elapsed will
still say "2 seconds".

While the application is not busy, I enabled the Timer and the second count
increases normally every second.

Is this means Timer control in VB.NET is not Asynchronous (like VB6 Timer
control) ? Or am I missing something? Please help!!!

Thanks in advance!!!

David

Jul 21 '05 #1
3 1826
The System.Windows.Forms.Timer runs on the same thread as the application.
So if your application is carrying out some processor-intensive task, the
timer ticks are not going to be fired since the thread is busy doing your
task. Instead, use the System.Timers.Timer (which runs on a seperate thread
than the application) and write your code in the Elapsed event of the timer.

hope that helps..
Imran.

"David" <no******@mailingspam.com> wrote in message
news:eS***************@TK2MSFTNGP09.phx.gbl...
Hi There!

I'm using Timer control to record how long my application perform certain
tasks.

However, apparently Timer control is not doing its' job (i.e. Not firing
Tick event) while my application is busy. So even if my application took 2
mins, the label that is used to show the number of seconds elapsed will
still say "2 seconds".

While the application is not busy, I enabled the Timer and the second count increases normally every second.

Is this means Timer control in VB.NET is not Asynchronous (like VB6 Timer
control) ? Or am I missing something? Please help!!!

Thanks in advance!!!

David

Jul 21 '05 #2
David wrote:
Is this means Timer control in VB.NET is not Asynchronous (like VB6 Timer
control) ? Or am I missing something? Please help!!!


The VB6 Timer control was never asynchronous. It worked exactly the same
as every other event driven component. When an event fires, the programs
instruction pointer is saved and then moved to the top of the event
handler procedure and will be returned to the saved address when the End
Sub runs in that event handler procedure.

Private Sub ABC()
1 code here
2 code here
3 code here
'timer event fires after running line 3
'code in timer's event handler runs
'returns to line 4 after the End Sub in the timer event
4 code here
5 code here
6 code here
End Sub

Private Sub Timer1_Timer()
'This entire procedure runs before
'returning to line 4 above
'it will never return until the line below runs
End Sub

--
Ken Halter - MS-MVP-VB - http://www.vbsight.com
Please keep all discussions in the groups..
Jul 21 '05 #3
> I'm using Timer control to record how long my application perform certain
tasks.

However, apparently Timer control is not doing its' job (i.e. Not firing
Tick event) while my application is busy. So even if my application took 2
mins, the label that is used to show the number of seconds elapsed will
still say "2 seconds".


Maybe you should use dateTime instead of a timer control.
COmpare the time before the task to the time after the task.

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.754 / Virus Database: 504 - Release Date: 9/6/2004
Jul 21 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: David | last post by:
Hi There! I'm using Timer control to record how long my application perform certain tasks. However, apparently Timer control is not doing its' job (i.e. Not firing Tick event) while my...
8
by: Stephen Rice | last post by:
Hi, I have a periodic problem which I am having a real time trying to sort. Background: An MDI VB app with a DB on SQL 2000. I have wrapped all the DB access into an object which spawns a...
4
by: Philip Wagenaar | last post by:
I have a Queue that contains filenames. I have a System.Timer with it's interval set to 200. I load the Queue up with 35.000 files. I start the Timer. On Timer.Elapsed I take a file from the...
7
by: RobKinney1 | last post by:
Hello, Wow...I have one for you all and hopefully I am not understanding this timer object correctly. I have a timer setup that pulses a connection through a socket every 60 seconds. But it...
3
by: | last post by:
Is it possible to have just a multithreaded sub procedure? What I need is a timer time_elapsed event (2 sec interval) send params to a sub that is multithreaded. I have a COM component used to...
2
by: Anatoli | last post by:
I've got an incrementTimer()-Function, which is called on mous click. It increments Windows.Forms.Timer interval and starts the timer... No problem so far. Now I want to do the same when...
5
by: Peted | last post by:
Just some threading questions 1. in a MDI app if you have multiple child forms, does each child form run in its own thread ? Eg do you get error trying to update one control on form1 from...
2
by: RP | last post by:
I have a Timer control on a form. When this Timer starts, it will do certain task on every tick. I want that this Timer be linked to a new thread so that the Timer does not disturb other...
8
by: Rainer Queck | last post by:
Hello NG, in my application I have a Panel, docked right to my Form. On this panel I draw - cyclic triggered by a System.Winforms.Timer - a bitmap using the Graphics class. using (Graphics g =...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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
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
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...

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.