Over the span of millions of years, the gas
in the protoplanetary disk dissipates -- perhaps
captured by planets -- and the star reaches
the main sequence. In other words, pressures and
temperatures inside the star become high enough
that fusion can occur.
Bennett et al.
It probably took our Sun around 10 million
years to collapse and arrive on the main
sequence. During that time, the planets in
our Solar System were accreting.