Yes, he was in the stasis chamber all the way through.
Which means for 139 years: from 1980 to 2119. But because it was a stasis chamber, he didn't age during that time, and it must have felt like only a moment for him. He'd programmed the chamber to open at the right moment on the instructions of his own 'ghost':
CLARA: And [your ghost] saying the chamber will open?
DOCTOR: That was me telling me to get inside and when to set it for.
As for your second question, he entered the stasis chamber off-stage while we were watching the Fisher King, shortly before the dam burst. Throughout the episode Under the Lake, he was both out in the base (where we saw him then) and also in the stasis chamber. But such is the nature of time travel: people can be in two places at once, as we also saw earlier on in Before the Flood when two copies of the Doctor and Bennett almost encountered each other.