<p data-telerik-id="Paragraph637567542110611335">
<span data-telerik-id="Span637567542110611345">
Test
</span>
</p>
public class HiResDateTime
{
private static long lastTimeStamp = DateTime.UtcNow.Ticks;
private static readonly Regex digitsOnly = new Regex(@"[^\d]");
public static long UtcNowTicks
{
get
{
long original, newValue;
do
{
original = lastTimeStamp;
long now = DateTime.UtcNow.Ticks;
newValue = Math.Max(now, original + 1);
} while (Interlocked.CompareExchange
(ref lastTimeStamp, newValue, original) != original);
return newValue;
}
}
public static string UtcNowTicksString => digitsOnly.Replace(UtcNowTicks.ToString(), "");
}