private CreateEvent_internal ( bool manual, bool initial, string name, bool &created ) : |
||
manual | bool | |
initial | bool | |
name | string | |
created | bool | |
return |
public EventWaitHandle(bool initialState, EventResetMode mode) { bool created; bool manual = IsManualReset(mode); Handle = NativeEventCalls.CreateEvent_internal(manual, initialState, null, out created); }
public EventWaitHandle(bool initialState, EventResetMode mode, string name, out bool createdNew) { bool manual = IsManualReset(mode); Handle = NativeEventCalls.CreateEvent_internal(manual, initialState, name, out createdNew); }
public EventWaitHandle(bool initialState, EventResetMode mode, string name) { bool created; Handle = NativeEventCalls.CreateEvent_internal((mode == EventResetMode.ManualReset), initialState, name, out created); }
/// <summary>Initializes a new instance of the <see cref="T:System.Threading.EventWaitHandle" /> class, specifying whether the wait handle is initially signaled if created as a result of this call, whether it resets automatically or manually, and the name of a system synchronization event.</summary> /// <param name="initialState">true to set the initial state to signaled if the named event is created as a result of this call; false to set it to nonsignaled.</param> /// <param name="mode">One of the <see cref="T:System.Threading.EventResetMode" /> values that determines whether the event resets automatically or manually.</param> /// <param name="name">The name of a system-wide synchronization event.</param> /// <exception cref="T:System.IO.IOException">A Win32 error occurred.</exception> /// <exception cref="T:System.UnauthorizedAccessException">The named event exists and has access control security, but the user does not have <see cref="F:System.Security.AccessControl.EventWaitHandleRights.FullControl" />.</exception> /// <exception cref="T:System.Threading.WaitHandleCannotBeOpenedException">The named event cannot be created, perhaps because a wait handle of a different type has the same name.</exception> /// <exception cref="T:System.ArgumentException"> /// <paramref name="name" /> is longer than 260 characters.</exception> public EventWaitHandle(bool initialState, EventResetMode mode, string name) { bool manual = this.IsManualReset(mode); bool flag; this.Handle = NativeEventCalls.CreateEvent_internal(manual, initialState, name, out flag); }
public EventWaitHandle(bool initialState, EventResetMode mode, string name) { if (null != name && System.IO.Path.MAX_PATH < name.Length) { throw new ArgumentException(Environment.GetResourceString("Argument_WaitHandleNameTooLong", name)); } Contract.EndContractBlock(); SafeWaitHandle _handle = null; #if MONO int errorCode; #endif switch (mode) { case EventResetMode.ManualReset: #if MONO _handle = new SafeWaitHandle(NativeEventCalls.CreateEvent_internal(true, initialState, name, out errorCode), true); #else _handle = Win32Native.CreateEvent(null, true, initialState, name); #endif break; case EventResetMode.AutoReset: #if MONO _handle = new SafeWaitHandle(NativeEventCalls.CreateEvent_internal(false, initialState, name, out errorCode), true); #else _handle = Win32Native.CreateEvent(null, false, initialState, name); #endif break; default: throw new ArgumentException(Environment.GetResourceString("Argument_InvalidFlag", name)); } ; if (_handle.IsInvalid) { #if !MONO int errorCode = Marshal.GetLastWin32Error(); #endif _handle.SetHandleAsInvalid(); if (null != name && 0 != name.Length && Win32Native.ERROR_INVALID_HANDLE == errorCode) { throw new WaitHandleCannotBeOpenedException(Environment.GetResourceString("Threading.WaitHandleCannotBeOpenedException_InvalidHandle", name)); } __Error.WinIOError(errorCode, name); } SetHandleInternal(_handle); }
public unsafe EventWaitHandle(bool initialState, EventResetMode mode, string name, out bool createdNew, EventWaitHandleSecurity eventSecurity) { if (null != name && System.IO.Path.MAX_PATH < name.Length) { throw new ArgumentException(Environment.GetResourceString("Argument_WaitHandleNameTooLong", name)); } Contract.EndContractBlock(); #if !MONO Win32Native.SECURITY_ATTRIBUTES secAttrs = null; #if FEATURE_MACL // For ACL's, get the security descriptor from the EventWaitHandleSecurity. if (eventSecurity != null) { secAttrs = new Win32Native.SECURITY_ATTRIBUTES(); secAttrs.nLength = (int)Marshal.SizeOf(secAttrs); byte[] sd = eventSecurity.GetSecurityDescriptorBinaryForm(); byte * pSecDescriptor = stackalloc byte[sd.Length]; Buffer.Memcpy(pSecDescriptor, 0, sd, 0, sd.Length); secAttrs.pSecurityDescriptor = pSecDescriptor; } #endif #endif SafeWaitHandle _handle = null; Boolean isManualReset; switch (mode) { case EventResetMode.ManualReset: isManualReset = true; break; case EventResetMode.AutoReset: isManualReset = false; break; default: throw new ArgumentException(Environment.GetResourceString("Argument_InvalidFlag", name)); } ; #if MONO int errorCode; _handle = new SafeWaitHandle(NativeEventCalls.CreateEvent_internal(isManualReset, initialState, name, out errorCode), true); #else _handle = Win32Native.CreateEvent(secAttrs, isManualReset, initialState, name); int errorCode = Marshal.GetLastWin32Error(); #endif if (_handle.IsInvalid) { _handle.SetHandleAsInvalid(); if (null != name && 0 != name.Length && Win32Native.ERROR_INVALID_HANDLE == errorCode) { throw new WaitHandleCannotBeOpenedException(Environment.GetResourceString("Threading.WaitHandleCannotBeOpenedException_InvalidHandle", name)); } __Error.WinIOError(errorCode, name); } createdNew = errorCode != Win32Native.ERROR_ALREADY_EXISTS; SetHandleInternal(_handle); }
public ManualResetEvent(bool initialState) { bool created; Handle = NativeEventCalls.CreateEvent_internal(true, initialState, null, out created); }
public EventWaitHandle(bool initialState, EventResetMode mode, string name, out bool createdNew, EventWaitHandleSecurity eventSecurity) { Handle = NativeEventCalls.CreateEvent_internal((mode == EventResetMode.ManualReset), initialState, name, out createdNew); }
public AutoResetEvent(bool initialState) { bool created; Handle = NativeEventCalls.CreateEvent_internal(false, initialState, null, out created); }