PDA

Click to See Complete Forum and Search --> : VB Threads?


jpeplinski
Feb 9th, 2001, 08:20 AM
Help!! I need to figure out the easiest and quickest way to limit the number of running instances my component has going on the server. Right now, I have an ActiveX server (exe) running on the server and called via DCOM from the clients. The problem is that too many instances are running at once and flooding our server.

I am willing to redesign pieces of this but would prefer to still use DCOM to keep the process on the server. How can I limit the number of threads? Can MTS handle this for me? Looking at MTS, I can't figure out how it limits the number of threads. I only want to have like 5 running at a time and each client just grabs the next available in round robin format or whatever works best.

Thanks so much!

simonm
Feb 9th, 2001, 10:44 AM
You can limit the number of threads of your ActiveX EXE by going into the project properties.

On the 'General' tab, select the 'Thread Pool' option and then select the maximum number of threads you wish to allow for your project.

N.B. This does not prevent more instances being created, it just means that further instances will be assigned to existing threads.

As for limiting the number of instances of your objects, this cannot be done within VB (Unless you want to limit your number of instances to one).

jpeplinski
Feb 9th, 2001, 12:44 PM
If I change the number of threads to 5, what happens when the 6th client machine tries to get an instance? Does it throw an error back to the calling pgm, or does it wait for 1 to free up?

Is it possible to keep the 5 instances running and the clients just grab them when they instantiate a new instance?

This server exe does some intensive things on load and it would be great to leave them in memory on the server.

Thanks to all in advance!

jpeplinski
Feb 9th, 2001, 01:08 PM
it is not what I expected. I changed my activex server to use 2 for the thread pool. I installed on the server and had 3 clients instantiate. It creates 3 running instances of it on the server. What am I missing here?

Thanks!

simonm
Feb 12th, 2001, 02:43 AM
Don't get them confused.

You can instantiate a class more than once in a single thread. If you have a limited thread pool, once all the threads are used up, An existing thread will be used and you will have two instances sharing the same thread.

Any global variables of the ActiveX EXE project will be shared between instances in the same thread.

Instances in different threads will have unique copies of the global variables.