Guest cgchris99 Posted August 2, 2002 Posted August 2, 2002 I have a app that I am writing. I launches a couple threads that run constantly. I have a timer in the thread to indicate how fast it is executing a loop. I need this loop to be FAST. It must be 5ms or less. If I put "thread.currentthread.priority.sleep(1)", the loop time is about 15ms. This is on a 2Ghz PC with 1024MB Ram. If I completely remove the sleep, it executes the loop in 0.013 ms. Yes, that's milliseconds. Ideally, I would like a happy medium of about 3-5ms scan time would be great. But the sleep command does not allow anything but an integer, sleep(0.5) produces the same as no sleep command. The only reason I ask is that I have other threads running and would like to give up some processing to the others during the "sleep" time. If I put application.doevents instead of sleep, the scan time fluctuates a lot. From 0.013 - 110ms. Thanks for any advice Quote
*Gurus* divil Posted August 2, 2002 *Gurus* Posted August 2, 2002 Set the threads priority to BelowNormal or Lowest. You shouldn't be using DoEvents in a loop in a thread you've created. Perhaps we could help more if you explained what you're doing with these loops. Quote MVP, Visual Developer - .NET Now you see why evil will always triumph - because good is dumb. My free .NET Windows Forms Controls and Articles
Guest cgchris99 Posted August 5, 2002 Posted August 5, 2002 One of the threads is scanning a memory address that is connected to a digital I/O board. I need to be able to see this input come on and go off. It triggers at approx every 200ms. So it must be fast. What I have found is even if I get the thread running really fast. Like a complete scan in 0.015 ms the O/S takes over at random to do maintenance and the scan time jumps to about 110ms. This is not acceptable. With a pause of 110ms I will completely miss the Digial I/O board trigger. Thanks for any further advice Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.