On Jan 31, 11:41 am, "Angelo" <angelo...@gmail.comwrote:
Ok,
I am utilizing the threadpool class to manage a number of threads.
Priority is not important to me and neither is if the threads are
background or foreground threads so I opted for the threadpool class.
The issue is that I am latebinding on several libraries that I have.
(They're actually plug-ins.) How would I send the methods to the
threadpool?
Any help would be much appreciated.
Angelo
Angelo,
Obtain a reference to a MethodInfo object that describes the method
you want to run and call Invoke on it from a ThreadPool thread.
If you're using C# 2.0 this is both easy and elegant using anonymous
methods.
Object obj = GetSomeObject("SomeObject");
ThreadStart method = delegate()
{
obj.GetType().GetMethod("SomeMethod").Invoke(obj, null);
};
IAsyncResult ar = method.BeginInvoke(null);
However, if you're plugins adhere to specific interface then you
shouldn't have to make late-bound calls at all.
Brian