namespace System;
public class CurrentTimeGetter
{
private static int lastTicks = -1;
private static DateTime lastDateTime = DateTime.MinValue;
///
/// Gets the current time in an optimized fashion.
///
/// Current time.
public static DateTime UtcNow
{
get
{
int tickCount = Environment.TickCount;
if (tickCount == lastTicks)
{
return lastDateTime;
}
DateTime dt = DateTime.UtcNow;
lastTicks = tickCount;
lastDateTime = dt;
return dt;
}
}
}