Threadpool LateBinding

A

Angelo

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
 
B

Brian Gideon

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top