A day with .Net

My day to day experince in .net

Passing arguments to a task

Posted by vivekcek on August 19, 2012

Look at the example below. Hope it is simple to understand.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace GetResult1
    class Program
        static void Main(string[] args)
            Task<int> t1 = new Task<int>(() => Add(1,2));
            Console.WriteLine("Result: {0}", t1.Result);
        static int Add(int a,int b)
            return a + b;


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s