Lets say you want to start a thread. How would you do it?
Thread T1 = new Thread(new ParameterizedThreadStart(SomeMethodName));
Restriction imposed by .NET is that Method which T1 targets can have only one parameter of object type. Hence, above code will work only if method signature is:
public static void SomeMethodName(object o)
public static void SomeMethodName(object o)
But what if I want to invoke a method like:
public static void xyz (int a, int b) ???
Answer is to use delegates here and start thread as:
Thread T3 = new Thread(delegate() { xyz(3, 4); });orThread T3 = new Thread(() => xyz(3, 4));
No comments :
Post a Comment
What are your thoughts on this post? Did you like it?