Solved

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

Posted on 2007-11-23
6
187 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
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

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 …
Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

744 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

16 Experts available now in Live!

Get 1:1 Help Now