title: Intermittent issues with Win32 named events
body: <p>Experiencing intermittent issues, related to named events when processes are running in different user contexts: WaitForSingleObject (and WaitForMultipleObjects too) for such event handle fails with WAIT_FAILED (GetLastError returns 6 - Invalid handle value).</p>
  
  <p>We have an application to schedule tasks on Windows machines under user accounts, and issue happens after some tasks are completed.</p>
  
  <p>Service part of application (JobManager) starting executable (JobLeader) under user account (CreateProcessAsUser) to run user task, and waiting for named event to be signaled.
  Manual reset named event is created by JobLeader in the "Global\" namespace and signaled when user task is completed.</p>
  
  <p>JobManager waiting in the loop, calling WFMO(WaitForMultipleObjects) with delay of 10 seconds, to see if named event or JobLeader process handle are signaled.</p>
  
  <p>Periodically named event handle, opened by JobManager through OpenEvent API call, causes WFMO (WFSO is also called after to identify which handle is broken) to return WAIT_FAILED, with error code 6 - "Invalid handle value".
  After reopening the event, this error may gone, or may not - WFMO may again returns WAIT_FAILED because of invalid handle value.</p>
  
  <p>Interesting, that it may pass few dozens tasks without this error, and then - sequentially few tasks have it. Tasks used for testing are identical - just a cmd.exe script, dumping environment.</p>
  
  <p>Anyone have ideas about this?</p>
  
  <p>Regards,
    Alex</p>