This was my mother's favorite filling. Old fashioned vanilla custard.
Mix sugar, cornstarch and salt in saucepan. Gradually stir in milk. Cook over medium heat, stirring constantly, until mixture thickens and boils. Boil and stir 1 minute.
Stir at least half of the hot mixture gradually into egg yolks. Stir back into hot mixture in saucepan. This is called tempering the yolks so they don't curdle.
Boil and stir 1 minute; remove from heat. Stir in margarine or butter and vanilla; cool.
Custard can easily scorch. You need to stir constantly.
Once you see the concoction bubbling, the mixture thickens. Temper the yolks, add them back to cook for a minute, then remove from burner to add the butter/magarine and vanilla.