Вопрос

I need to delay some piece of code from processing for some time in Microseconds. I tried a lots of things such as thread.Sleep(x), but it has only milliseconds resolution.

I am using .NET 2.0 in MS Visual Studio 2013.

Это было полезно?

Решение

 System.Diagnostics.Stopwatch

allows you to get very small (few nanosecond) ticks, which you can convert to microseconds using this. Then you can just let an empty while loop for as long as you need.

Edit: and it even is supported by .NET 2.0.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top