Click here to Skip to main content
15,888,579 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How Lamda expression inside is able to access data variable without even being passed?

C#
public Task<Bitmap> RenderAsync(ImageData data, CancellationToken cancellationToken)
{


    return Task.Run(() =>
    {

        var bmp = new Bitmap(data.Width, data.Height);
        for (int i = 0; i < data.Width; i++)
        {
            cancellationToken.ThrowIfCancellationRequested();
            for (int j = 0; j < data.Height; j++)
            {


            }
        }
        return bmp;

    },cancellationToken);
Posted
Comments
Tomas Takac 6-Feb-14 17:37pm    
This is called a closure. You can find plenty of articles describing it. For example here.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900