Fri, August 22, 2008, 07:26 PM under
ParallelComputing
Steps:1. New C# Console Project in VS2008
2. Add Reference to
System.Threading.dll
(from
Parallel Extensions June CTP)
3. Replace the entire contents of
Program.cs
with the following (overly simplified extract of a more complex piece of code):
using System;
using System.Threading.Tasks;
static class Program
{
static void Main()
{
Task t1 = Task.Create(delegate
{
Task t2 = Task.Create( // breakpoint #1
(o) =>
Console.WriteLine(o.ToString()) // breakpoint #2
, "hey");
t2.Wait(); // breakpoint #3
});
t1.Wait(); // breakpoint #4
Console.ReadLine(); // breakpoint #5
}
}
4. Insert a breakpoint (F9) wherever there is a comment.
Questions:A. Without running the project, what can you predict about which breakpoints will be hit and in what order?
B. Can you predict at each breakpoint, which of the two variables (
t1
,
t2
) is in scope (e.g. if they were in the Watch window)?