473,402 Members | 2,064 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,402 software developers and data experts.

Help: Threading a timer

How do I put a timer in it's own thread? The reason I need this is that I
may have like 30 timers going continuously and it's more efficient (right??)

Thanks.
Nov 20 '05 #1
8 1147
Cor
Hi VB programmer

Take a look at "system.timers.timer"

I thought that has already itself his own thread.

And don't use forms.form.timer, that you can drag from the desinger,

Just and advice

Cor

Nov 20 '05 #2
How do I "attach" code to the timer, adjust interval properties, etc... if I
use "system.timers.timer"?

"Cor" <no*@non.com> wrote in message
news:3f**********************@reader20.wxs.nl...
Hi VB programmer

Take a look at "system.timers.timer"

I thought that has already itself his own thread.

And don't use forms.form.timer, that you can drag from the desinger,

Just and advice

Cor

Nov 20 '05 #3
Cor
Hi VB programmer

When you search on MSDN with system.timers.timer

You get some links

This is one of them
http://msdn.microsoft.com/library/de...asedtimers.asp

But there are furthermore a lot.

I hope this helps,

Cor
Nov 20 '05 #4
Hi VBP, Cor,

Actually there are <three> sets of Timers.

Forms.Timer is the familiar drag-n-drop one.

System.Timers.Timer is one that can be used without a Form. It's
similar in use in that it raises an Event to which a class in your app
subscribes.

http://msdn.microsoft.com/library/de.../cpref/html/fr
lrfsystemtimerstimerclassctortopic.asp

System.Threading.Timer is one which you provide a callback method.
When the Timer goes off, this method is called in its own Thread.

http://msdn.microsoft.com/library/de.../cpref/html/fr
lrfsystemthreadingtimerclassctortopic2.asp

Ok, that's the choices. There's a (typically MSDN) example with each.

Is it more efficient? First some questions: ;-)

What are they for?
How often will they go off?
Same interval for each?
Staggered or all at once?
What jobs will get done?
How long will the jobs take?

Regards,
Fergus
Nov 20 '05 #5
Cor
Hi Fergus,

More minimal four.

(And I don't mean datetime and things like that)

Cor
Nov 20 '05 #6
Ho Cor,

Lol. More? Excellent - can't have too few Timers. ;-)

What did I miss?

Regards,
Fergus
Nov 20 '05 #7
Cor
Hi Fergus,

I was helping someone together with OHM and then suddenly I saw a timer I
never had seen. It was something like the Strconv function. It exist but if
you haven't seen it and you won't believe that such a simple and small
function exist.

But this timer had no advantages, so I forgot it, I only did remember that
there was another one (I hope it was not a bad dream). I did not found it
again now by searching and I find it is to unimportant, the three you
mentioned where the most important I think.

But there are more timers, this I did find in a search in
"time-to-reach-queue timer".

I was busy a while with those timers, the problem is that espacialy the form
and the stystem timer workint totaly different so in the documentation you
have to watch very carefully what you are using.

And now I use automaticly the thread.sleep, that is easy to manage and with
an do application.event you can do everything with it even in threads, but
of course very inaccurate.
(When I tell it how I use it I get standard a message from Herfried).

But that is of course not good answer to an OP who ask for a timer.

:-)
Cor
Nov 20 '05 #8
Hi Cor,

Thanks. If that function does turn up.. well, I'm curious now. ;-)

~~ I hope it was not a bad dream

I've been dreaming all morning (before I was fully awake) that a pizza and
ingredients that I got ready lat night were missing. As the dream was mixed up
with languages.vb thoughts, it was very strange. The pizza's still three
though. Maybe it's an important post that's missing.

I believe that the Timers use Sleep themselves. The Forms one has a
resolution of 55ms which is adequate for UI work. I'm not sure of the
Timers.Timer one. The Threading one is 1ms, as is Sleep itself. [There was a
query in vb.winapi from a guy who couldn't get his below 10ms. Something about
not setting it right - but that was WinApi not .NET]

Using Thread.Sleep is perfecty valid - as you say it's very
straightforward - and may be a better solution than using Timers so I'd put
the idea forward - let the OP decide. ;-)

Cheers,
Fergus
Nov 20 '05 #9

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

Similar topics

0
by: Dmitry Demchuk | last post by:
Hi everybody. Recently I ran into situation with System.Threading.Timer in my ASP.NET application. I reinstalled Windows on one of my servers and got timers stop firing events after while, they...
3
by: ELO | last post by:
Hi all Every week, I need to get two files on a remote server. I have developped a C# Windows Service with two System.Threading.Timer to do this task For the first one, the delay (TimeSpan...
4
by: Hagay Lupesko | last post by:
Hi, I've encountered a strange phenomena which appears to me as a bug: I have an engine that uses a System.Threading.Timer to invoke a delegate every X minutes. The code looks something...
2
by: hnkien | last post by:
Hi, I am writing a windows service with threading.timer for 10 seconds but it didn't work. Here are my code: namespace SchedulerService { public class ScheduleService :...
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...
2
by: linesh.gajera | last post by:
Hi Guys, I am creating a Windows service that call a routine at given interval. Once routine is complete, windows service should wait for 5 minutes and then call the routine again. I was using...
6
by: whtinkm | last post by:
Hi, All Recently, my project need some code like following: using System; using System.Threading; namespace MyTimerTest { class Class1 {
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...
2
by: KSC | last post by:
Hello, I have used a thread timer as in the documentation on MSDN in my VB.NET application. Using System.Threading.Interlocked.Increment I increment the counter to a certain point, perform an...
4
by: Lemune | last post by:
Hello everyone. I'm using vb 2005. I'm creating program that run as service on windows. And in my program I need to use timer, so I'm using timer object from component. I try my source code on...
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: 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: 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
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
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...
0
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,...
0
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...

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.