ついでに: adding a task while taking care of another
Use ついでに for an extra task done on the occasion of a main activity. Learn its verb and noun connections and distinguish this relationship from doing two things simultaneously.
Which activity is the main purpose?
買い物に行くついでに、郵便局に寄ります。 means that the speaker will stop by the post office while going out shopping. Shopping is the main reason for the outing; the post office is an additional stop made using that opportunity.
郵便局に行くついでに、買い物をします。 makes the post office the main destination instead. Both sentences involve the two activities, but they present different primary purposes.
Connecting verbs and nouns
Verbs connect in the dictionary or ta-form, and nouns take の. 散歩のついでに、牛乳を買いました。 means that the speaker bought milk while out for a walk. Learn the noun connection with の rather than treating 散歩ついでに as the basic form.
書類を届けたついでに、担当者に質問しました。 means that the speaker asked the person in charge a question on the occasion of delivering documents. The ta-form views the first action as completed, but does not specify an exact time interval between the tasks.
An opportunity differs from ながら
In 音楽を聞きながら歩きました。, listening and walking happen at the same time. 散歩のついでにパンを買いました。 instead adds buying bread to the opportunity of taking a walk; it does not mean continuously buying bread while walking.
You can also ask someone already going to the station, 駅に行くついでに、この手紙を出してもらえますか。, to mail a letter along the way. The expression itself does not guarantee that the extra task is a small burden for the other person.
Quick check: In 図書館に行くついでに、銀行に寄りました。, which activity is presented as the main one?
Show the answer and why
Going to the library. The speaker used that opportunity to stop by the bank; the sentence does not say the two activities happened simultaneously.

