While working on the homework, John remembers that he hasn't had lunch yet.
The sentence above omits "he is" in the while clause because the subject is the same as the following main clause *and* the actions of "working" and "remembers" both happen at the same time.
I just wonder whether the rule for using "after"/"before" is the same. If not, could anyone explain how to use "after" and "before" if the subjects are the same.
Thanks.