Foreshadowing is a literary technique used to allow writers to hint at an event which is in the offing. It has gotten a bad name and for good reason. It is often done clumsily and as a substitute for a good story. An example:
Mary entered the ballroom. It was all shine and glass. Suddenly, she heard a large clap behind her. She whirled. The floor to ceiling mirror had a large crack. And as if in slow motion, the pieces loosened from the frame and toppled to the ground. “I have a bad feeling about this,” she thought.
Okay, so I went for the clichés. But there are plenty others. Stormy weather to denote disturbance in the characters’ world. Ravens or crows abounding doom. Spilled wine presages flowing blood. A shattered mirror portents the destruction of a life, a hope, an idyll. Or even, as in the piece above, a character saying, “I have a bad feeling about this.”
The intent of all of these is to signal to the reader that something BIG is coming.
Foreshadowing versus building tension
The reason I don’t favor foreshadowing much is that I think writers can sometimes use it as a proxy. Instead of putting the time and effort into building tension in a story, they figuratively and sometimes literally tell the reader, oh, this is going to get exciting, oh, you’re going to be so surprised, look at how tense things are getting. It’s sort of a tell in that the writer isn’t necessarily constructing a plot which builds and builds tension so the reader can decide herself when she’s excited, surprised, or tense. Instead, the writer signals the expected response. Let’s try the Mary-ballroom thing again.
Mary entered the ballroom, checking to make sure she was alone. She sauntered down the large space, noting the floor-to-ceiling mirrors, and the sunshine bouncing off the highly polished floors. “Like a downmarket Versailles,” she thought. And then she smiled.
Obviously, you need more than a couple of lines to build good, rip-roaring tension. But in this segment, there are possible clues in Mary’s actions. She makes sure that she’s alone which might suggest furtiveness but then she sauntered in the room which is more associated with being carefree. And what was it with the thought about downmarket and the smile? Why did she do that?
You can build tension through the character’s actions rather than tired old tropes.
I don’t want to suggest that foreshadowing is never appropriate. But it needs to be subtle, perhaps so subtle that the reader, at most, takes it in unconsciously. Then it can be quite effective. The novelist Carol Shields advocates the use of foreshadowing so that “when the denouement arrives, it will both surprise and satisfy some level of expectation.” When used well, it can contribute to the reader’s feeling that the ending was the ‘right’ one.
So, when/if you use foreshadowing, apply with a light hand. Leave the hammers for stories that start out with It was a dark and stormy night.
 Shields, Carol, Startle and Illuminate: Carol Shields on Writing Random House, Canada, 2006