Delegate and multithreading
what is the difference between multithreading and delegate in C#?
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend4days leftRegister
VulpesRank #55 · 29.2K reputationPosted Nov 9, 2011, 11:18 AM EST
delegate int MyDelegate(int i);
class Test
{
public int Square(int i)
{
return i * i;
}
}
you can assign the method to the delegate and call it via the delegate like this:
Test t = new Test();
MyDelegate d = t.Square;
int result = d(9); // 81
Multi-threading simply means that there are multiple threads of execution running simultaneously within a particular process. If you only have a single processor, this is an illusion - the operating system allocates a 'time slice' to each thread in such a way as to make it appear to the user that the threads are running simultaneously when in fact they're sharing processor time.