diff --git a/csharp/core/Common.cs b/csharp/core/Common.cs index 7646f1e9..e43dcd7f 100644 --- a/csharp/core/Common.cs +++ b/csharp/core/Common.cs @@ -24,13 +24,14 @@ namespace AlibabaCloud.TeaUtil public static class Common { private static readonly string _defaultUserAgent; - private static readonly _processStartTime; + private static readonly long _processStartTime; private static long _seqId = 0; static Common() { _defaultUserAgent = GetDefaultUserAgent(); - _processStartTime = Process.GetCurrentProcess().StartTime; + double ticks = (DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc)).TotalSeconds; + _processStartTime = (long)(ticks * 1000); } public static byte[] ToBytes(string val) @@ -136,7 +137,7 @@ public static string GetNonce() long currentTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(); long seq = Interlocked.Increment(ref seqId); long randNum = new Random().NextInt64(); - string msg = $"{process_start_time}-{thread_id}-{current_time}-{seq}-{randNum}"; + string msg = string.Format("{0}-{1}-{2}-{3}", _processStartTime, threadId, currentTime, seq, randNum); using (MD5 md5 = MD5.Create()) { byte[] hash = md5.ComputeHash(System.Text.Encoding.UTF8.GetBytes(msg));