Is Environment.TickCount the impact of system time?

I am wondering how the .NET BCL Environment.TickCount property is implemented. In particular, I would like now if this affects the system time settings .

My first assumption about how the property was implemented was that it was just a managed wrapper around the GetTickCount method , indicated that it was affected by adjustments made by the GetSystemTimeAdjustment function, but the documentation for Environment.TickCount says nothing about time settings.

I am trying to find out if Environment.TickCount can be used (albeit with low accuracy), constantly increasing the time value.

+3
source share
2 answers

No, it Environment.TickCountdoes not depend on the system time settings. It was my interpretation of the documentation, but my curiosity required more complex proof, so I had the following code when setting up the system back and forth for one hour:

while (true)
{
    Console.WriteLine(Environment.TickCount);
    Thread.Sleep(1000); 
}

... and the result showed an ideal sequence that was not affected by the time adjustments.

Update
Therefore, I did some more homework caused by a question from Marcus in the comments below. I am quite sure (I can’t confirm that) that Environment.TickCount is accessed GetTickCount, which has the following meanings in the docs:

GetTickCount , 10 16 . GetTickCount , GetSystemTimeAdjustment.

, , , , SetSystemTimeAdjustment.

+4

, .

" ", . MSDN:

32- . , , TickCount Int32.MaxValue 24.9 , Int32.MinValue, , 24.9 .

+2

Source: https://habr.com/ru/post/1724928/


All Articles