March 2004
Intermediate to advanced
560 pages
26h 47m
English
public delegate void ThreadStart ();
|
JR It is a pity that this delegate wasn't defined with an Object parameter, allowing the creator of the thread to pass some initialization data into the new thread. To get initialization data into a new thread, you need to define a class, add fields to the class, and add the thread method (whose prototype matches this delegate) to this class. Then, when you want to create a thread, you construct an instance of the object, set the fields to the desired initialization data, and new up the Thread object, passing the ThreadStart delegate wrapped around the thread method that's defined in the class. When the thread starts running, it can access the fields. |
Read now
Unlock full access