Jump to content
Xtreme .Net Talk

vb.net, Threads & Sleep Command???


Recommended Posts

Guest cgchris99
Posted

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

Guest cgchris99
Posted

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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...