/// <summary>
/// Generate a custom 15-digit Guid code according to the millisecond value of the current time
/// </summary>
/// <returns></returns>
public static string Generate()
{
lock ( locker)
{
string guid = DateTime.Now.ToString("yyyyMMddHHmmssfff"); // Get the millisecond string of the current time
Thread.Sleep(1); // The thread is suspended for 1 millisecond to ensure that the millisecond value has changed in the next execution
guid = new Random().Next(1, 10).ToString() + guid; // To make the generated Guid irregular, add a random number in front.
return long.Parse(guid).ToString("X").ToLower(); // Convert to hexadecimal lowercase string
}
}