Start task work with named methods so each worker body remains traceable.

task `Task.Run` can receive a method group, keeping the concurrent worker logic in ordinary named methods.

Task Method Group

seed
TaskMethodGroup.cs
Replay: real traced execution (multi-file project)
using System;
using System.Threading.Tasks;

class Program
{
    static int baseValue;

    static int CalculateLeft()
    {
        int result = baseValue + 3;
        return result;
    }

    static int CalculateRight()
    {
        int result = baseValue * 2;
        return result;
    }

    static void Main()
    {
        int seed = 5;
        baseValue = seed;

        Task<int> left = Task.Run(CalculateLeft);
        Task<int> right = Task.Run(CalculateRight);

        int total = left.Result + right.Result;
        Console.WriteLine($"seed={seed}");
        Console.WriteLine($"total={total}");
    }
}
using System;
using System.Threading.Tasks;

class Program
{
    static int baseValue;

    static int CalculateLeft()
    {
        int result = baseValue + 3;
        return result;
    }

    static int CalculateRight()
    {
        int result = baseValue * 2;
        return result;
    }

    static void Main()
    {
        int seed = 2;
        baseValue = seed;

        Task<int> left = Task.Run(CalculateLeft);
        Task<int> right = Task.Run(CalculateRight);

        int total = left.Result + right.Result;
        Console.WriteLine($"seed={seed}");
        Console.WriteLine($"total={total}");
    }
}
using System;
using System.Threading.Tasks;

class Program
{
    static int baseValue;

    static int CalculateLeft()
    {
        int result = baseValue + 3;
        return result;
    }

    static int CalculateRight()
    {
        int result = baseValue * 2;
        return result;
    }

    static void Main()
    {
        int seed = 8;
        baseValue = seed;

        Task<int> left = Task.Run(CalculateLeft);
        Task<int> right = Task.Run(CalculateRight);

        int total = left.Result + right.Result;
        Console.WriteLine($"seed={seed}");
        Console.WriteLine($"total={total}");
    }
}
  1. seed ← 5, baseValue ← 5, left ← System.Threading.Tasks.Task`1[System.Int32]

    20static void Main()21{22    int seed→ 5 = 5; //@seed=2, 823    baseValue→ 5 = seed5;2425    Task<int> left→ System.Threading.Tasks.Task`1[System.Int32] = Task.Run(CalculateLeft);26    Task<int> right→ System.Threading.Tasks.Task`1[System.Int32] = Task.Run(CalculateRight);
  2. result ← 8

    8static int CalculateLeft()9{10    int result→ 8 = baseValue5 + 3;11    return result8;12}
  3. result ← 10

    14static int CalculateRight()15{16    int result→ 10 = baseValue5 * 2;17    return result10;18}
  4. total ← 18

    28    int total→ 18 = left.Result8 + right.Result10;29    Console.WriteLine($"seed={seed5}");30    Console.WriteLine($"total={total18}");31}
    outputseed=5
    total=18
  1. seed ← 2, baseValue ← 2, left ← System.Threading.Tasks.Task`1[System.Int32]

    20static void Main()21{22    int seed→ 2 = 2;23    baseValue→ 2 = seed2;2425    Task<int> left→ System.Threading.Tasks.Task`1[System.Int32] = Task.Run(CalculateLeft);26    Task<int> right→ System.Threading.Tasks.Task`1[System.Int32] = Task.Run(CalculateRight);
  2. result ← 5

    8static int CalculateLeft()9{10    int result→ 5 = baseValue2 + 3;11    return result5;12}
  3. result ← 4

    14static int CalculateRight()15{16    int result→ 4 = baseValue2 * 2;17    return result4;18}
  4. total ← 9

    28    int total→ 9 = left.Result5 + right.Result4;29    Console.WriteLine($"seed={seed2}");30    Console.WriteLine($"total={total9}");31}
    outputseed=2
    total=9
  1. seed ← 8, baseValue ← 8, left ← System.Threading.Tasks.Task`1[System.Int32]

    20static void Main()21{22    int seed→ 8 = 8;23    baseValue→ 8 = seed8;2425    Task<int> left→ System.Threading.Tasks.Task`1[System.Int32] = Task.Run(CalculateLeft);26    Task<int> right→ System.Threading.Tasks.Task`1[System.Int32] = Task.Run(CalculateRight);
  2. result ← 11

    8static int CalculateLeft()9{10    int result→ 11 = baseValue8 + 3;11    return result11;12}
  3. result ← 16

    14static int CalculateRight()15{16    int result→ 16 = baseValue8 * 2;17    return result16;18}
  4. total ← 27

    28    int total→ 27 = left.Result11 + right.Result16;29    Console.WriteLine($"seed={seed8}");30    Console.WriteLine($"total={total27}");31}
    outputseed=8
    total=27