Exemplo n.º 1
0
        private static SafeWaitHandle CreateSemaphore(int initialCount, int maximumCount, string name)
        {
#if !PLATFORM_WINDOWS
            if (name != null)
            {
                throw new PlatformNotSupportedException(SR.PlatformNotSupported_NamedSynchronizationPrimitives);
            }
#endif

            Debug.Assert(initialCount >= 0);
            Debug.Assert(maximumCount >= 1);
            Debug.Assert(initialCount <= maximumCount);

            return(Win32Native.CreateSemaphoreEx(null, initialCount, maximumCount, name, 0, AccessRights));
        }
Exemplo n.º 2
0
        private static SafeWaitHandle CreateSemaphore(int initialCount, int maximumCount, string name)
        {
            if (name != null)
            {
#if PLATFORM_UNIX
                throw new PlatformNotSupportedException(SR.PlatformNotSupported_NamedSynchronizationPrimitives);
#else
                if (name.Length > Interop.Kernel32.MAX_PATH)
                {
                    throw new ArgumentException(SR.Format(SR.Argument_WaitHandleNameTooLong, name, Interop.Kernel32.MAX_PATH), nameof(name));
                }
#endif
            }

            Debug.Assert(initialCount >= 0);
            Debug.Assert(maximumCount >= 1);
            Debug.Assert(initialCount <= maximumCount);

            return(Win32Native.CreateSemaphoreEx(null, initialCount, maximumCount, name, 0, AccessRights));
        }