Passing In Data To A Thread
In this lecture, you will learn how to safely pass initialization data to a thread. You will learn about the ParameterizedThreadStart delegate, and how to use a lambda expression to initialize a thread.
Captured variables in lambda expressions are shared between the new thread and the main program thread, and so this opens us up to a possible race condition.
I will show you a short program that uses a lambda expression and introduces a race condition. Then I'll show you a cool trick, where I only change 2 lines of code, to make the race condition disappear.