创建顺序 Guid 时RPC_S_UUID_LOCAL_ONLY的重要性



我复制从 http://www.dbdelta.com/improving-uniqueidentifier-performance/中截取的以下代码来创建顺序 Guid:

private static Guid NewSequentialGuid()
        {
            const int S_OK = 0;
            const int RPC_S_UUID_LOCAL_ONLY = 1824;
            Guid oldGuid = Guid.Empty;
            int result = UuidCreateSequential(ref oldGuid);
            if (result != S_OK && result != RPC_S_UUID_LOCAL_ONLY)
            {
                throw new ExternalException("UuidCreateSequential call failed", result);
            }
            byte[] oldGuidBytes = oldGuid.ToByteArray();
            byte[] newGuidBytes = new byte[16];
            oldGuidBytes.CopyTo(newGuidBytes, 0);
            // swap low timestamp bytes (0-3)
            newGuidBytes[0] = oldGuidBytes[3];
            newGuidBytes[1] = oldGuidBytes[2];
            newGuidBytes[2] = oldGuidBytes[1];
            newGuidBytes[3] = oldGuidBytes[0];
            // swap middle timestamp bytes (4-5)
            newGuidBytes[4] = oldGuidBytes[5];
            newGuidBytes[5] = oldGuidBytes[4];
            // swap high timestamp bytes (6-7)
            newGuidBytes[6] = oldGuidBytes[7];
            newGuidBytes[7] = oldGuidBytes[6];
            //remaining 8 bytes are unchanged (8-15) 
            return new Guid(newGuidBytes);
        }

让我感到困惑的是&& result != RPC_S_UUID_LOCAL_ONLY检查。我不明白为什么/何时应该或不应该检查此值。

有人可以澄清一下吗?我可以离开这个结帐还是会遇到问题?

感谢@Damnien_The_Unbeliever让我对显而易见的事情大开眼界。

最新更新