Below is a code snippet on how this can be done!
class Program
{
static void Main(string[] args)
{
Thread thread = new Thread(() => { Sum(2, 1); });
thread.Start();
Console.Read();
}
public static void Sum(int a, int b)
{
Console.Write(a + b);
}
}
What happens here is that when the code is compiled, and anonymous method is created which then points to the Sum method! Give it a go!
Awesomeness, I'll definately use this. Hopefully I wont get super thread happy due to its ease of use...
ReplyDeleteWhats nice about this, is thats its super easy to add a callback on when the thread has finished. I will write a blog on that too soon!
ReplyDelete