Re: Threadpool LateBinding

Tech-Archive recommends: Fix windows errors by optimizing your registry



On Jan 31, 11:41 am, "Angelo" <angelo...@xxxxxxxxx> wrote:
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

.



Relevant Pages

  • Re: ThreadPool Help
    ... > create a mutex and place this mutex in a shared collection. ... > shared collection, and then exit. ... >> ThreadPool Class to invoke the delegate. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: ThreadPool and contacting remote resources
    ... > I know that the ThreadPool class is used internally by various .NET classes. ... > request happened at a time when the ThreadPool's max threads are close to ...
    (microsoft.public.dotnet.languages.csharp)
  • Threadpool LateBinding
    ... 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 ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Multi-threaded Worker Objects
    ... I think that a ThreadPool is your friend:) ... ThreadPool class. ... instances of the client application will connect to this singleton ... workerprocess objects which actually ...
    (microsoft.public.dotnet.framework.remoting)
  • Re: How to tell if all the threads in a ThreadPool have completed/finished
    ... > I have created a piece of code that uses a ThreadPool class and the ... > QueueUserWorkItem method to add items to the the ThreadPool. ... to stash tons of items in the thread pool (either directly by ...
    (microsoft.public.dotnet.languages.csharp)