Ecco un esempio semplicissimo:
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace MultiThreading
{
class Program
{
static void Main(string[] args)
{
int[] a = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
int[] b = { 11, 12, 13, 14, 15, 16, 17, 18, 19, 20 };
int[] c = new int[10];
int i1=0, i2=5, i3=10;
List<Task> tasks = new List<Task>();
{
tasks.Add(Task.Run(() =>
{
for (int i = i1; i < i2; i++)
c[i] = a[i] + b[i];
}));
tasks.Add(Task.Run(() =>
{
for (int j = i2; j < i3; j++)
c[j] = a[j] + b[j];
}));
}
Task.WaitAll(tasks.ToArray());
for (int i = 0; i < i3 ; i++)
Console.Write($"{c[i]}, ");
Console.WriteLine();
}
}
}