/// <summary>
        /// Opens an existent event object with the specified name.
        /// </summary>
        /// <param name="name">The name of the global Event.</param>
        /// <returns>The opened event object.</returns>
        public static NamedEvent OpenNamedEvent(string name)
        {
            IntPtr handler = WindowsAPI.OpenEvent(WindowsAPI.EVENT_ALL_ACCESS, 0, name);

            if (handler == IntPtr.Zero)
            {
                throw GenuineExceptions.Get_Windows_CanNotCreateOrOpenNamedEvent(Marshal.GetLastWin32Error());
            }
            return(new NamedEvent(handler));
        }
        /// <summary>
        /// Creates named event object.
        /// </summary>
        /// <param name="name">The name of the event object.</param>
        /// <param name="initialState">If this parameter is TRUE, the initial state of the event object is signaled; otherwise, it is nonsignaled.</param>
        /// <param name="manualReset">If this parameter is FALSE, the function creates an auto-reset event object, and system automatically resets the state to nonsignaled after a single waiting thread has been released.</param>
        /// <returns>Created event object.</returns>
        public static NamedEvent CreateNamedEvent(string name, bool initialState, bool manualReset)
        {
            if (WindowsAPI.FailureReason != null)
            {
                throw OperationException.WrapException(WindowsAPI.FailureReason);
            }

            IntPtr handler = WindowsAPI.CreateEvent(WindowsAPI.AttributesWithNullDACL,
                                                    manualReset ? 1 : 0,
                                                    (initialState ? 1 : 0), name);

            if (handler == IntPtr.Zero)
            {
                throw GenuineExceptions.Get_Windows_CanNotCreateOrOpenNamedEvent(Marshal.GetLastWin32Error());
            }
            return(new NamedEvent(handler));
        }