private static Exception _HandleErrorCode(int errorCode, string name, SafeHandle handle, object context)
{
System.Exception exception = null;
switch (errorCode)
{
case Interop.Errors.ERROR_INVALID_NAME:
case Interop.Errors.ERROR_INVALID_HANDLE:
case Interop.Errors.ERROR_FILE_NOT_FOUND:
if ((name != null) && (name.Length != 0))
exception = new WaitHandleCannotBeOpenedException(SR.Format(SR.WaitHandleCannotBeOpenedException_InvalidHandle, name));
else
exception = new WaitHandleCannotBeOpenedException();
break;
default:
break;
}
return exception;
}