Heat Milk:
In a medium saucepan, combine milk, 1/4 cup sugar, and salt. Heat over medium heat until it begins to simmer. Remove from heat.
Whisk Egg Mixture:
In a separate bowl, whisk together egg yolks, remaining 1/4 cup sugar, and cornstarch until smooth and pale.
Temper Eggs:
Slowly pour about 1/2 cup of the hot milk into the egg mixture while whisking constantly. This prevents the eggs from curdling.
Cook Custard:
Pour the tempered egg mixture back into the saucepan with the remaining milk. Cook over medium heat, whisking constantly, until the mixture thickens and comes to a gentle boil (about 2–3 minutes).
Finish with Butter and Vanilla:
Remove from heat and whisk in butter and vanilla extract until smooth and glossy.
Cool:
Transfer pastry cream to a bowl. Cover with plastic wrap directly on the surface to prevent a skin from forming. Chill in the refrigerator for at least 2 hours before using.