private AutoResetEvent TryGetOrCreateWriterEvent()
{
// The intention is to catch all exceptions, so that the caller can try again. Typically, only OutOfMemoryException
// or any SystemException would be thrown. For instance, the EventWaitHandle constructor may throw IOException if
// the Windows CreateEvent function fails due to low system resources. The idea is that any exception that may be
// thrown will propagate to the user on a different path, through AcquireWriterLock.
try
{
return GetOrCreateWriterEvent();
}
catch
{
return null;
}
}