You use barely to say that something is only just true or only just the case. Anastasia could barely remember the ride to the hospital It was 90 degrees and the air conditioning barely cooled the room His voice was barely audible = scarcely
hence, scarcely; hardly; as, there was barely enough for all; he barely escaped
If you say that one thing had barely happened when something else happened, you mean that the first event was followed immediately by the second. The Boeing 767 had barely taxied to a halt before its doors were flung open
by a small margin; "they could barely hear the speaker"; "we hardly knew them"; "just missed being hit"; "had scarcely rung the bell when the door flew open"; "would have scarce arrived before she would have found some excuse to leave"- W B Yeats