I am using this code where I am invoking the run method of a List of classes that I loaded dynamically from dlls:
for (int i = 0; i < robotList.Count; i++) { Type t = robotList[i]; //robotList is a List<Type> object o = Activator.CreateInstance(t); t.InvokeMember('run', BindingFlags.Default | BindingFlags.InvokeMethod, null, o, null); }
The invokeMember is invoking the run methodof each of the classes in the list.
Now how can I invoke this run method from invokeMember in a separate Thread ? So that I’ll have separate threads running for each of the invoked methods.
If you know that all your dynamically loaded types implement Run, could you just require they all implement IRunable and get rid of the reflection part?
If not, this will work: