コード例 #1
0
        private static SafeWaitHandle CreateSemaphone(int initialCount, int maximumCount, string name)
        {
            if (name != null)
            {
#if PLATFORM_UNIX
                throw new PlatformNotSupportedException(Environment.GetResourceString("PlatformNotSupported_NamedSynchronizationPrimitives"));
#else
                if (name.Length > Path.MAX_PATH)
                {
                    throw new ArgumentException(Environment.GetResourceString("Argument_WaitHandleNameTooLong", name));
                }
#endif
            }

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

            return(Win32Native.CreateSemaphore(null, initialCount, maximumCount, name));
        }
コード例 #2
0
        private static SafeWaitHandle CreateSemaphone(int initialCount, int maximumCount, string name)
        {
            if (name != null)
            {
#if PLATFORM_UNIX
                throw new PlatformNotSupportedException(SR.PlatformNotSupported_NamedSynchronizationPrimitives);
#else
                if (name.Length > Path.MaxPath)
                {
                    throw new ArgumentException(SR.Format(SR.Argument_WaitHandleNameTooLong, Path.MaxPath), nameof(name));
                }
#endif
            }

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

            return(Win32Native.CreateSemaphore(null, initialCount, maximumCount, name));
        }