In Act 1, Scene 2, Horatio, Marcellus and Bernardo tell Hamlet about seeing what appeared to be his father's ghost on the battlements. At the very end of that scene when Hamlet is all alone, he says to himself:
My father's spirit--in arms! All is not well.
I doubt some foul play. Would the night were come!
Till then sit still, my soul. Foul deeds will rise,
Though all the earth o'erwhelm them, to men's eyes.
These lines are mainly intended as foreshadowing. In fact, the whole of Scene 2 might be considered foreshadowing. The audience has seen the ghost and is naturally very curious about its purpose in visiting the castle. But Shakespeare delays the meeting between Hamlet and the ghost by inserting Scene 3, in which Laertes and Ophelia have a conversation and then Polonius appears and gives his son his parting advice, ending with the famous words:
This above all: to thine own self be true,
And it must follow, as the night the day,
Thou canst not then be false to any man.
Then Laertes exits and Polonius has a conversation with his daughter Ophelia, ending with his ordering her not to have any more private conversations with Hamlet for fear of the Prince's ulterior motives.
That scene contains still more foreshadowing. The audience knows that there must be a scene in which Hamlet and Ophelia will have a lovers quarrel. But they are still waiting to see what will happen when Hamlet finally meets the ghost. All of this is brand-new to Shakespeare's audience. They know nothing about Claudius' treachery. Shakespeare is getting the ultimate emotional impact from this ghost--and then in Scene 4 there is still some further delay before the ghost finally appears. Shakespeare satisfies the audience's curiosity fully by devoting the lengthy Scene 5 to the encounter between Hamlet and his father's spirit. Hamlet finds that his premonition about "some foul play" was correct.