try this:

Thread.Sleep(17*1000 / (1000*1000*1000))

argument takes time in millisecond. So, 3 times 1000 is to create 10^9 and 17*1000 is to remove its arguments' millisecond.

Did you see the constructor, it says (int millisecondTimeout). so it assumes every thing in millisecond. to cancel millisecond effect I multiplied it with 1000.

Dear Mr.Ayyub,

yes i understand.
thanks a lot. you are amazing.
i hope this will work. i can check it after tomorrow

Did you see the constructor, it says (int millisecondTimeout). so it assumes every thing in millisecond. to cancel millisecond effect I multiplied it with 1000.

And you have an expression "17*1000 / (1000*1000*1000)" which gives 0.000017 i.e. 17 nsec.
But, if the constructor takes an integer (int millisecondTimeout), value 0.000017 will be actually zero.

Here's a thread nanosecond delay and a quote from the thread:

The closest you can come, is by using a Stopwatch. But again, it "only" support ticks, and one tick is 100 nanoseconds.

This means that PC hardware, as seen from the .NET, can't measure times like 17 nsec.

One other thing, from the OS point, is the thread where "the delay is executed". Assuming you would manage to construct a "magical loop" which has an execution time of 17 nsec. and that loop is run in the UI thread, how can you be sure that OS doesn't swap out, for one reason or other, your loop in the middle of the execution?

Happy New Year 2011

hello,

so what am supposed to do i need to interface switches that has a 30MHz clock frequency using my parallel port??? am very new to programming, do how can i make this possible ??

please help

thanks

I suggest reading the link I gave first. You can also google similar articles. Not articles related to VB.NET itself but more like engineering articles that talk about controlling devices with PC.

It may be that you need some additional tools to VB.NET. I mean you may have to use a lower level language i.e. assembler to get precise enough timings. You could also check if Windows API provides any methods for high precise timings.

HTH

This article has been dead for over six months. Start a new discussion instead.