获取系统启动后经过的毫秒数。
需要注意溢出的情况。
' Sample for the Environment.TickCount property. ' TickCount cycles between Int32.MinValue, which is a negative ' number, and Int32.MaxValue once every 49.8 days. This sample ' removes the sign bit to yield a nonnegative number that cycles ' between zero and Int32.MaxValue once every 24.9 days. Imports System Class Sample Public Shared Sub Main() Dim result As Integer = Environment.TickCount And Int32.MaxValue Console.WriteLine("TickCount: {0}", result) End Sub 'Main End Class 'Sample ' 'This example produces the following results: ' 'TickCount: 101931139
本文介绍了一种通过调整TickCount属性值来获取系统启动后经过的毫秒数的方法,该方法避免了整数溢出的问题,并提供了一个周期性的输出结果,适用于长时间运行的应用程序。
5910

被折叠的 条评论
为什么被折叠?



