Why, Thank You, X!

While this can appear in almost any genre (an especially likely variation is for it to masquerade as a killer Right Behind You in a slasher flick, or some other form of Meaningful Background Event, before revealing its true nature), its origin is actually as a Comedy Trope.

A person is performing an activity—searching, eating, looking at something, and so on—and as he or she is thus occupied, someone beside or behind them helps them out: pointing out where the object they're looking for is, explaining what they're trying to understand, or making some random comment about whatever they're doing. The person replies, usually distractedly or absentmindedly, with the Stock Phrase of the trope title, or a variation thereof, returning to what they were doing—only to suddenly do a Double Take and whirl around to face X. Usually this would be because X is someone whom they thought was dead, missing, far away, or otherwise impossible to encounter at that place and time.

A specific Sub-Trope of Stealth Hi Bye, where the appearance of the person out of nowhere is always played for laughs and the emphasis is upon the startled character's initial reaction as if nothing is out of the ordinary. May be related to Failing A Spot Check. Quite often occurs because a character isn't paying proper attention. Can be a trick The Obi-Wan or the Eccentric Mentor pulls on his pupil after he has Ascended To A Higher Plane Of Existence.

Anime and Manga

 * In Episode 6 of Umineko no Naku Koro ni this happens when Siesta 410 receives ammo from Gaap

Comic Books
"Riddler: Where is my Phillips head screwdriver? [a gloved hand gives him the screwdriver from offscreen] Oh, thank you! [a question mark appears over his head, then he's yanked out of the panel by Batman]"
 * Happens in Elf Quest (TOQ #16) when the mysterious muffled figure helping Leetah to heal the dying Cutter turns out to be, whom she thought had died years before (and had what seemed like evidence to prove it).
 * Appears in Batman Gotham Adventures #1. The Riddler is in his hideout working on a device.

Film

 * The archaeologist in The Fifth Element: "Thank you, Aziz!"

Live-Action TV

 * Doctor Who: The Doctor has a much retarded one of these (as in, it takes him minutes to realize he is telling Rory to be quiet and let him think, when Rory was utterly erased from space and time a few episodes ago) in "The Pandorica Opens". He actually exits the scene without noticing, leaving Rory nonplussed, before striding back in with a look of deep confusion to poke Rory in the chest.
 * Of course, considering the nature of the Eleventh Doctor, it was entirely in character.

Oral Tradition, Myths and Legends

 * A ghost story: A man wakes up in the middle of the night and wishes for light to comfort himself. He reaches for the matches and gets handed a lit one. No one is visible.

Theatre

 * Depending On The Director, Bottom's return in A Midsummer Night's Dream

Western Animation

 * This happens a lot in Scooby Doo, especially when Scooby and Shaggy decide to cook or just fool around after splitting up. The monster/ghost makes an appearance handing them something or offering a suggestion before they see it and run for their lives.
 * It also happened to Velma when she was in a college lab testing a mummy's bandages to find out if they were really ancient and the mummy handed her a test tube with the right chemical in it. (In retrospect, it's also kind of a clue that the mummy is one of the professors.)