I’m constructing an anonymous object:
var userToken = new {myMsg = Msg, myTimer = timer};
and passing it to an event handler:
smtp.SendCompleted += SendCompletedCallback;
private static void SendCompletedCallback(object sender, AsyncCompletedEventArgs e)
{
var msg = e.UserState;
}
Inspecting msg shows that it contains the values I’ve passed but I’m not clear on the syntax that allows me to access those values in my code.
To improve Jordao’s answer: