Usually it becomes clear fairly early who is going to win, but sometimes it is much closer and it may not be clear until the Convention - especially if there are three or more main candidates, in which case the votes would be split, and no one candidate has a majority. There was a convention not so long ago in which they had to vote loads of times before agreeing on the winner. And of course in 1968, the Democratic Party Convention had to elect a replacement after the assassination of Robert Kennedy.