Solved

How would I go about using mulitple timer's efficiently?

Posted on 2007-11-23
6
192 Views
Last Modified: 2010-04-23
I am planning on using a Timer to "poll" an PCI card that controls two different axis of a machine. I need to have at LEAST one Timer constantly getting information from the PCI card to display any fault that the servos might run into. There are also times where I am going to need to have 2-3 more timers polling the PCI card for Inputs/Outputs that are currently on and other information that needs to be updated relatively quickly (I am shooting for <1 sec). Is there any good way to go about this? Or is have 3 or 4 timers (ticks at 1 sec) executing simultaneously not a problem?


Not sure if this matters, but I would assume it would have some effect: The program will be running on a new AMD 4000+ X2 Proc, XP pro, and 1 gig or memory.
0
Comment
Question by:Gssc1414
  • 3
  • 3
6 Comments
 
LVL 55

Accepted Solution

by:
Jaime Olivares earned 500 total points
ID: 20339990
would be more efficient a single timer with the proper granularity. But you have to notice that in this approach, will attend event sequentially, so if one event lasts more than 1 second, by example, another event can keep unattended for a while.
separate timers allows you to attend event virtually simultaneously, but this will depend also if your PCI card will not get confused with this.
0
 
LVL 3

Author Comment

by:Gssc1414
ID: 20340113
Would it be possible to use multi-threading? Maybe put each timer on it's own thread? Or even just the critical ones on a separate thread than that of the program? I don't know much about multi-threading, so im not sure if this is feasible, and if it is, if it would really help me out that much or not.



Jaime,

Thanks for your quick response!
I will have to check into the PCI card and make sure this won't be a problem.
0
 
LVL 55

Expert Comment

by:Jaime Olivares
ID: 20340161
In fact you don't need to do multithreading explicity. Timers are multithreaded implicity.
Just create many timers and launch them. Each timer have it own Tick event that run in a separate thread.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 3

Author Comment

by:Gssc1414
ID: 20340179
Alright, good deal. One last one for ya! Can I explicitly set a priority to different timers?


P.S. I upped the point value because of your extremely fast and precise answers. I really appreciate the help!
0
 
LVL 55

Expert Comment

by:Jaime Olivares
ID: 20340196
What do you want to do with a "priority timer" ?
Do some tasks sequentialy when timer collide? or do them in parallel with a differnent speed?

For first, I suggest a priority queue, for second use a regular thread an simulate a timer with an infinite loop with delay.

BTW, you have to check also if the API you are using to interface the PCI card will accept concurrency
0
 
LVL 3

Author Comment

by:Gssc1414
ID: 20347101
Very well. It looks like I am a little confused. I once again apologize for my lack of knowledge. I will take your advice and go with it.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…
Delivering innovative fully-managed cloud services for mission-critical applications requires expertise in multiple areas plus vision and commitment. Meet a few of the people behind the quality services of Concerto.

947 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now