.

threading – parameterized

lambda: Thread thread = new Thread(() => download(filename));

c# 2.0 Thread thread = New Thread(delegate() { download(filename); });

long way:
var thread = new Thread(new ParameterizedThreadStart(download));

others:

 ThreadPool.QueueUserWorkItem( () => value = Process(value)); // use captured variable

 
// -- OR --

 
ThreadPool.QueueUserWorkItem( () =>
     
{
           
double val = value;      // use explicit parameter
           val
= Process(val);      // v is not changed
     
});

 
// -- OR --

 
ThreadPool.QueueUserWorkItem( (v) =>
     
{
           
double val = (double)v;  // explicit var for casting
           val
= Process(val);      // v is not changed
     
}, value);



BOOKS!

What's your thoughts on this?

*

Protected by WP Anti Spam