Click here to Skip to main content
15,894,720 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello All,

Is it possible to make my application wait for a period of nano seconds?
?

Help please.
Posted
Updated 30-Dec-10 20:09pm
v2
Comments
CPallini 5-Jan-11 17:25pm    
Have a look at this illuminating article of Luc Pattyn: http://www.codeproject.com/KB/cs/LP_TimerTest.aspx

Windows is not that accurate. Abotu the best you can do is get a delay mesaured in microseconds. Since Windows is a shared system, it can and will be doing other things that will delay your codes return from such a function call that "sleeps" your process. Without specialized hardware and software, you cannot achieve that kind of accuracy and resolution on a Windows machine.
 
Share this answer
 
purchase a ChronoLogic USB-inSync and consult their COM utilities.

Look at the documentation for a TimeSpan:

"The smallest unit of time is the tick, which is equal to 100 nanoseconds." (TimeSpan.Ticks[^])

That's the absolute best resolution of time that you are going to get without third-party hardware.
 
Share this answer
 
v2
Comments
William Winner 6-Jan-11 12:43pm    
WTF? purchasing third-party hardware is the only way that you will be able to measure nano-seconds. So, who has a problem with that answer?
Its going to be tough to be accurate to nano seconds using a VB.Net timer.
As per this[^] article, the precision of the timer is only in milliseconds.

You might want to consider some API's to do this task.
 
Share this answer
 
Comments
alaayesh 31-Dec-10 2:59am    
Hi,

the timer interval property takes also integers only and in milliseconds??

thanks
Hi
You can use

C#
//1 millisecond = 1 000 000 nanoseconds

System.Threading.Thread.Sleep(NanoSec);


Thanks,
Imdadhusen
 
Share this answer
 
Comments
alaayesh 31-Dec-10 2:57am    
hi,

but this only takes milliseconds and as integer and i need to wait for 17nS??

thanks a lot
Dave Kreskowiak 5-Jan-11 16:57pm    
Read the documentation on Thread.Sleep again. The argument it takes is measured in milliseconds, not nanoseconds. 1 millisecond = 1,000,000 nanseconds.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900