It can be several hours — even days — from the time you mark your X on a ballot and stuff it into a ballot box (or in some cases, into a mailbox) to when someone actually counts it and you hear the election result through the media.

Here's what happens along the way:

When are ballots counted?

Ballots cast on election day are counted once the polls in that riding close.

Ballots cast in advance — with some exceptions we'll get to later — are also counted on election day, also once the polls close.

How is the counting done?

Once the polls close in your riding, the two election workers (poll clerk and deputy returning officer) who have been in charge all day of the ballot box your vote went into — are now in charge of counting all the votes that box contains.

They start by counting the number of names crossed off their electors list. They check that number against the number of paper ballots they had at the start of the day, minus spoiled or unused ballots.

If the numbers match up, they start to count the votes for each candidate. They also count rejected votes.

(By the way, if the numbers don't match up, the poll workers have to count again. If they still don't match up, and there is a minor imbalance, Elections Canada says the count will be completed with notes and explanations, if possible).

But back to the standard counting process.

Ballot counting during the 2013 Nova Scotia election. (Preston Mulligan/CBC)

During this stage of the counting, candidate scrutineers or electors from the riding are in the room to observe — but they are not allowed to report the results while the count is ongoing.

Once the counting is finished, the results are called in to the riding's local Elections Canada office, where they are tallied and entered into the wider Events Results System. Those results are transmitted to Elections Canada headquarters in Gatineau, Que., and on to the media consortium.

At that point, they start to pop up on the Elections Canada website and on TVs, radios and online screens across the country.

What about special ballots?

Special ballots include mail-in ballots, votes cast by overseas members of the military or by incarcerated Canadians. These are the exceptions we mentioned earlier.

They get counted at Elections Canada headquarters and that count can begin up to eight days before election day. As each batch of special ballots is counted, the results are entered into a results system.

An interesting tidbit: the staff counting those special ballots gets rotated regularly so that no one can figure out result trends based on vote tallies from earlier batches.

The special ballot results are held until a half hour after polls close on election day. At that point, the results are sent to the appropriate local Elections Canada office and they are added to all the other riding results and ultimately transmitted through the media.

When are the advance polls counted?

Advance polls for the federal election were open from October 11 to 14, 2019. (Michael Wilson/CBC)

Once the four-day advance vote has ended, the ballot boxes are either kept in a secure room at the advance polling location or brought to the local returning office and kept in a secure location.

They are not counted until election day.

This year, there were 4.7 million advance votes cast over the four days of advance voting, a 25 per cent increase over 2015.

A recent change to election law allows for the counting of advance polls to begin one hour before polls close. But the results cannot be released until after polls close.

Do the parties get the results before the rest of Canadians do?

They could conceivably — but only by a matter of minutes.

Remember we said there can be candidate scrutineers in the room when the ballots are being counted? Once the count is finished and the poll workers are calling in the results to the local Elections Canada office, the candidate scrutineers (if there were any in the room) are free to call their candidate and relay the results, and the candidate could then tell party officials.

Elections Canada says it would all come down to who makes phone calls faster. Again, it would likely be a matter of only minutes if there were a difference.

What time will Canadians start to get results?

From the time polls close, Elections Canada says it usually takes about 30 to 45 minutes for the first results from a ballot box to begin arriving in the Media Consortium system and be reported on TV, radio, or online.

Results start to show up in the news media about 30 to 45 minutes after polls close. (CBC)

Why do some results come faster than others?

If there aren't that many ballots in a ballot box, those results will be available pretty quickly. A really full box will take longer to count.

And if there was a high number of votes cast in the advance polls — as there were this year — that can lead to delays and then sudden surges in numbers.

And sometimes, a poll worker just can't reach anyone at Elections Canada to report the results. Those results will either be delayed, or perhaps not even be reported on election night.

And just one more important note

The result of the vote reported on election night is preliminary. In the days after, returning officers double-check all the reports and paperwork and confirm final results. They are then published on Elections Canada's website and considered official.