There are several overloads of AutoResetEvent.WaitOne()
When the signal.Set() signal is triggered, the signal.Set() method returns true to all overloads.
In a timeout overload, signal.WaitOne(timeout) returns false when the timeout expires.

And what about the overload without signal.WaitOne() parameters?
Can it return only true and never false ?

    1 answer 1

    WaitOne() causes another overload:

    https://referencesource.microsoft.com/#mscorlib/system/threading/waithandle.cs,212

     public virtual bool WaitOne () { //Infinite Timeout return WaitOne(-1,false); } 

    Next comes the call to the static method InternalWaitOne :

    https://referencesource.microsoft.com/#mscorlib/system/threading/waithandle.cs,235

     [System.Security.SecurityCritical] // auto-generated internal static bool InternalWaitOne(SafeHandle waitableSafeHandle, long millisecondsTimeout, bool hasThreadAffinity, bool exitContext) { if (waitableSafeHandle == null) { throw new ObjectDisposedException(null, Environment.GetResourceString("ObjectDisposed_Generic")); } Contract.EndContractBlock(); int ret = WaitOneNative(waitableSafeHandle, (uint)millisecondsTimeout, hasThreadAffinity, exitContext); if(AppDomainPauseManager.IsPaused) AppDomainPauseManager.ResumeEvent.WaitOneWithoutFAS(); if (ret == WAIT_ABANDONED) { ThrowAbandonedMutexException(); } return (ret != WaitTimeout); } 

    WaitOneNative then calls the WinAPI function WaitForSingleObjectEx . So WaitOne with no parameters will either return true , or throw an AbandonedMutexException . Since WaitForSingleObjectEx cannot return WAIT_TIMEOUT status if an infinite timeout is specified.

    https://docs.microsoft.com/en-us/windows/desktop/api/synchapi/nf-synchapi-waitforsingleobjectex