delegate and multithreading
what is the difference between multithreading and delegate in C#?
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
VulpesPosted Nov 9, 2011, 4:18 PM
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.