Geeks With Blogs

News Google

Nick Harrison Blog<Nick>.Next()

I have been playing around with lambda syntax and some of its implications.

 

I came across a rather clever way to launch a simple thread.

 

 

(new System.Threading.Thread(() =>

{

Function(param);

}

)).Start();

 

 

Of course if all you have is a single line, you can replace it with:

 

(new System.Threading.Thread(() => Function(param))).Start();

 

This makes it real simple to call a method in a separate thread. This can be very useful and make it very easy to build more responsive logic.

Sadly it also makes it very easy to abuse threads and more likely to code yourself in a corner.

Posted on Thursday, July 1, 2010 12:24 PM | Back to top


Comments on this post: Single Line threading with Lambdas

comments powered by Disqus

Copyright © Nick Harrison | Powered by: GeeksWithBlogs.net