 Wharton became a member of the First Troop Philadelphia City Cavalry in 1798 and served as its captain from 1803 to 1811.In 1810, the six troops of cavalry in the city were organized into a regiment, of which Wharton was elected colonel.Later, he was elected brigadier-general of the state militia.