r/programminghorror • • Dec 17 '25

A chain of (System.Threading.Tasks.)Tasks

Post image

Note: The "CompanyName" prefix in the EventArgs class was actually the name of the company this masterpiece was built for.

192 Upvotes

18 comments sorted by

View all comments

Show parent comment

1

u/The_Coalition Dec 21 '25

Wait, how does this even work? Isn't newTask inside the ContinueWith callback always equal to null? Or does the value of newTask inside the callback change together with newTask on the outside?

EDIT: okay, apparently I don't know how closures capture variables in C#. So much for my years of using C#