I am trying to figure out any issues with calling
System.Reflection.MethodInfo.Invoke() when dealing with multiple threads.
For instance..
Say I have a class that allows you to pass in a string that represents a
method name and an object that represents an instance of some class which
contains the previous function name. Now, I want to execute that method name
by calling the Invoke() method of MethodInfo similar to the following
example.
object Instance; //Represents the object that has the method to execute.
String MethodName; //The method to execute.
System.Reflection.MethodInfo Info;
Info = Instance.GetType().GetMethod(MethodName);
Info.Invoke(Instance, null);
Now what rules need to be followed when doing this type of stuff when
multiple threads are around.
Say that Instance is a WinForm and when the method in MethodName is execute
it accesses some GUI controls?
I have heard mention of BeginInvoke() before or something like that for
executing methods that are in different threads.. Does the Invoke() method
used above work in that same manner?
Any thoughts/suggestions would be appreciated.