C#: what is the operator => doing?

Hi Experts:

I saw a section of C# code:
          System.Threading.ThreadPool.QueueUserWorkItem((state) =>
                System.Threading.Thread.Sleep(3 * 1000);
                Dispatcher.BeginInvoke(() => BusyNote.IsBusy = false); }

Can anybody tell me what is the operator "=>" doing? and what is this section of code doing?
I know it is related to threading , but I don't understand the syntax involving "=>"

This section of code is from a SilverLight 4 application.

Thank you.
Who is Participating?
Reza RadConnect With a Mentor Consultant, TrainerCommented:
=> is LAMBDA operator,
there are lots of useful things you can do with Lambda operator, take a look at these links:

Algol36Connect With a Mentor Commented:
Over and above this code use anonimous method equivalent to the following:
void MyMethod()
  BusyNote.IsBusy = false;
funazonkiConnect With a Mentor Commented:
It might help to look at a simpler example - the lambda operator allows you to define anonymous functions that can be passed to other functions as parameters. The case you use above is a parameterless function. you can also define functions that take parameters. For example the following code calls the Count function that takes a boolean function as a parameter and returns the number of elements in the list for which the boolean is true.

                List<string> data = new List<string> { "one", "two", "three" };

The Console.WriteLine will write "2" to the console.
huangs3Author Commented:
reza_rad has the earliest and the most important answer while Algol36 and funazonik provided the helpful examples.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.