static void Main(string[] args)
{
Task<int> t = new Task<int>(Work);
t.Start();
Thread.Sleep(3000); // doing smth in main thread
t.ContinueWith(t => Console.WriteLine("job is done " + t.Result));
}
static int Work()
{
Console.WriteLine("work thread");
Thread.Sleep(1000); // doing smth in other thread
return 123;
}
output
work thread
job is done 123