W podręczniku do nauki c# znalazłem pewien przykład, lecz nie potrafię go do końca zrozumieć. Skoro wywołanie metody następuję synchronicznie to działają w niej dwa wątki ? Bo jeśli dwie czynności wykonują się w tym samym czasie to mamy do czynienia z dwoma wątkami ?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Diagnostics;
using System.Threading;
namespace Test
{
static class Program
{
public delegate int BinaryOp(int x, int y);
static int Add(int x, int y)
{
Console.WriteLine("Add() invoked on thread {0}.",
Thread.CurrentThread.ManagedThreadId);
Thread.Sleep(5000););
return x + y;
}
static void Main(string[] args)
{
Console.WriteLine("Main() invoked on thread {0}.",
Thread.CurrentThread.ManagedThreadId);
BinaryOp b = new BinaryOp(Add);
int answer = b(10, 10);
Console.WriteLine("10 + 10 is {0}", answer);
Console.ReadLine();
}
}
}