Use "as I was ___ing , ___" to describe when something suddenly happened while you were doing some other continuing action. For example:
As I was getting ready for work, I suddenly felt a sharp pain in my chest.
You can put the "as I was" part at the end as well:
She called out to me as I was about to get on the bus.
This is similar to "meanwhile", but "meanwhile" can be used to describe what two (or more) different people did:
James got started on supper. Meanwhile, Emma and I worked on her math homework and Brad went off to his room, probably to play X-box.
"As I was ___ing" is used to describe two things that happened to the same person at the same time. One of the events is continuous ("riding the train"), and the other is an action that happens quickly ("realized that...").