Salient Solutions

wrasslin ones and nones for fun and profit - Sky Sanders' Blog
Get your own ranked flair here
posts - 92, comments - 102, trackbacks - 0

Short: Inline multithreading with lambdas

Not going to write a novel. just a snippet. Mayhaps will explain when I am sure I know what I am talking about.
private static void InlineThreadingWithLambda()
{
    int local = 0;

    var thread = new Thread(() =>
                                {
                                    // just like javascript closures, you 
                                    // can take advantage of vars that are in
                                    // scope right now. Same pitfalls as well.
                                    local = 1;
                                });

    thread.Start();
    thread.Join();

    Console.ReadLine();
}

Technorati tags: ,

Print | posted on Wednesday, December 16, 2009 3:03 AM | Filed Under [ CodeProject-Tip ]

Feedback

No comments posted yet.

Post Comment

Title  
Name  
Email
Url
Comment   
Please add 6 and 7 and type the answer here:

Powered by: