Combine the sugar and cornstarch in a saucepan; gradually add milk, stirring with a whisk until well-blended. Stir in chocolate. Bring to a boil over medium heat; cook 7 minutes, stirring constantly. Gradually add hot milk mixture to egg, stirring constantly with a whisk. Return the milk mixture to the pan, and cook until thick and bubbly (about 30 seconds), stirring constantly. Remove from heat, and stir in the vanilla. Spoon the mixture into a bowl; place plastic wrap over the surface, and cool to room temperature.