473,394 Members | 1,773 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,394 software developers and data experts.

Link Timer to a new thread

RP
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 activities. How to
create a new thread and link this Timer to it?

Aug 29 '07 #1
2 1949
Hi,

"RP" <rp*********@gmail.comwrote in message
news:11**********************@q3g2000prf.googlegro ups.com...
>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 activities. How to
create a new thread and link this Timer to it?
You do not need to "link" the timer to the thread (or threads to be more
precise).
Just create a new thread in the Tick event.
In case ou need to have access to the UI from these threads use
Control.Invoke
Aug 29 '07 #2
RP wrote:
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 activities. How to
create a new thread and link this Timer to it?
In addition to what Ignacio already wrote...

It seems to me that if you necessarily want the timer-signaled code to
execute on a different thread, then one of the Timer classes that
actually use a different thread for signaling the timer would be a
better solution than using the Forms.Timer class.

Forms.Timer is great for situations when you specifically want the
timer-signaled code executing on the main UI thread and the resolution
is sufficient for your needs. But it sounds like you want the opposite
(not executing on the main UI thread) and so using Forms.Timer is
counter-productive.

Also, if you still wind up for whatever reason assigning a different
thread to the code in response to the signaling of the timer, it would
probably be better to use a thread pool thread rather than creating a
whole new one. This is a general rule, not absolute advice. As the
timer interval is longer, and the code executed takes more time, the
overhead of creating a brand new thread is made relatively smaller and
isn't as big a problem.

Pete
Aug 29 '07 #3

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

Similar topics

5
by: Richard P | last post by:
I need some help on timers. My app is asp.net 1.1 website running in a shared hosting environment with a third-party service provider. I currently request and cache 20 - 40 remote RSS feeds. When a...
8
by: Daniel P. | last post by:
I'm trying to set a timer that gets called every 3 seconds so I can update a field in the UI with the time elapsed since the process started. What am I doing wrong that timerDF_Tick does not get...
6
by: Dan | last post by:
I've created a pocketpc app which has a startup form containing a listview. The form creates an object which in turn creates a System.Threading.Timer. It keeps track of the Timer state using a...
8
by: theinvisibleGhost | last post by:
I think I've found a bug in the timer control. I've got a class which uses a timer control. It imports it from System.Windows.Forms This timer ticks once a second, and then updates a label...
3
by: mjheitland | last post by:
Hi, I like to know how many threads are used by a Threading.Timer object. When I create a Threading.Timer object calling a short running method every 5 seconds I expected to have one additional...
5
by: Tony Gravagno | last post by:
I have a class that instantiates two Timer objects that fire at different intervals. My class can be instantiated within a Windows Form or from a Windows Service. Actions performed by one of the...
5
by: Kate77 | last post by:
Hello, Im trying to do something very simple but having problems.. What I want to accomplish sounds simple but I cant find anywhere on the web answer of how to do that so it will work. I want...
2
by: Johnny Jörgensen | last post by:
I've got a process I want to run in a thread separate from my main application thread, so I've used a backgroundworker component, and in frmMain.Load I invoke the code using...
3
by: Steve | last post by:
Hi All I am using VB.net 2008 and use timer controls within my applications Question Does the code in a Timer control.tick event run on a different thread to the main Application thread (UI...
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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,...
0
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...

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.