Which one you need to use depends on whether you (or the speaker) consider the beginning and end of the action, or if you consider the action to be completed. This can be tricky for English speakers to understand because both tenses are usually translated the same in English.