"whichever is appropriate" is too vague for a detailed question regarding a time slot of mere seconds.
In general it is "simultanously".
Because "in general" people might try to execute simultanous tasks: noticing the other('s importance to greet), acknowledging that a greeting with handshake is expected, interrupt your current doing & thinking (=start a complete new situation), evaluate the other's social state, coordinate your body movement & talking, ...
In Germany there should be no ethical reason to avoid handshaking in the first place. Should be = my understanding of "german culture" sees handshaking with unknown persons I will talk a while / gonna welcome / is part of group I meet / ... a normal thing. Regardless gender, "race", age, ...
=> any attempt to avoid handshaking needs to be triggered by the other.
Then there are some differences:
- a single person vs. a group of persons (related to who you greet)
- level of "formal": from a unknown postman to a queen
- how far away have you been since eye contact?
- is it from context or culture even a good thing to shake hands?
- might happen "when you see each other" - because you have a reason to greet thus you are still unsure if hand shaking is appropriate
group of persons:
- when you have to greet every single of them, it comes "from move forward to handshake" - because the time frame is very small as you need to pass along to the next
level of "formal":
- "postman": possibly no handshake at all
- any business contact: depends more on single/group of people
- any "high official": there is a protocol which someone will explain to you beforehand (and this detail might still lack)
- level of "formal" determines which greeting is (more or less) appropriate
- the closer you are in the beginning, the less it is even possible to distinguish between these three moments
- it seems uncommon to say the greeting with the intention to handshake if you are more than an arm's lenght away
- big question is: do you handshake or not?
- yes: see above for further
- no: well, why no? one of both might refuse: having the cold / being unable to free hand from any glove (in time) / no handshake between male & female / ...