1

I made a VB6 EXE ActiveX that is used by a windows service and I would like to know if there any possibility to have several processes of this exe simultaneously in task manager ?

For example, we use AltovaXML_COM.exe to perform XSL transformation and each time I create an instance a new process is created, so in task manager we have severals independant processes.

Is there possible with VB6 exe ActiveX ?

Our exe Active X creates svg files and we want to perform severals generation of these files simultaneously.

Thanks for your help

user1069516
  • 443
  • 1
  • 7
  • 19
  • 1
    The entire point of an ActiveX EXE is to have one process handle many requests, so it's really not clear what you're actually trying to accomplish. I suspect you're dealing with an XY problem. –  Apr 27 '18 at 18:48
  • No, it's not a xy problem, our exe works correctly but if it was possible to have several processes like altova, I thought that maybe it could be possible to enhance performances and execution time. – user1069516 Apr 30 '18 at 07:29
  • Do you have more than one class module in your server? How have you set the `Instancing` property of those classes? – Jim Mack Apr 30 '18 at 13:31
  • Yes there are severals classes but just one is instanciated by C# windows service – user1069516 Apr 30 '18 at 14:37
  • Yes, and how have you set the `Instancing` property of those classes? – Jim Mack Apr 30 '18 at 18:20

2 Answers2

2

Yes, it is possible. The default behavior of an ActiveX exe is to have every application that creates a reference to your exe share a single instance of it in a single process. If you want to change this so that each reference creates its own separate exe in a separate process, then change the Instancing property from MultiUse to SingleUse.

You can't do this programmatically at runtime; you have to do it in the IDE. In the Project window, click on the class, and you'll see the Instancing property in the Properties window.

Another thing you may want to experiment with as a possible alternative is the threading model. The default, again, is one process handling all references (MultiUse) but also a single thread handling all references. To change this, you can go into the Project properties (bottom selection on the Project menu) and look at the Threading Model area in the lower right of the dialog box.

The default is a thread pool with one thread. If you change this to "thread per object" you will create a new thread each time you create a reference to your ActiveX Exe. You can also change the thread pool number to add more threads to it. If you do this, the threads are assigned on a round robin basis: if you have, say, five threads in your pool and six instances, two of the instances (VB won't tell you which, so beware) will share the first thread.

So, if you need multiple instances of your EXE, then change the instancing property to SingleUse. But if you are looking to enhance performance and execution time, you might find that multiple threads in one process is something to investigate as well.

BobRodes
  • 5,990
  • 2
  • 24
  • 26
  • Thank you for your help, it's exactly what I wanted to do but infortunately performances are worse. I thought that performances will be better with one process per task but it is not the case, performances are 30% worse. Do you know why ? – user1069516 May 02 '18 at 08:56
  • Probably has to do with process creation overhead, which is pretty high. You mention that you create a new process each time you create an instance, and if you don't use the instance for very long and create a lot of them your bottleneck is going to be the process creation. You might consider trying MultiUse, thread per object and see where that takes you (creating a new thread each time instead of a new process). [Here's](https://groups.google.com/forum/#!topic/microsoft.public.vb.general.discussion/wgqAjchqmwg) a discussion with some useful insights; check Tom Shelton's posts. – BobRodes May 02 '18 at 18:55
1

Every instance of an AX EXE will show up as a separate entry (process) in the task manager. One program can instantiate an AX EXE several times, or multiple programs may instance it one of more times. This isn't something the AX EXE does by itself, it's something other programs using the AX EXE do.

Jim Mack
  • 1,070
  • 1
  • 7
  • 16
  • Thanks for your answer, but altova_com.exe do that. It's a COM exe that registered by cmd with /regserver like ActiveX exe, and each time a new instance is created, a new process is created too so I thought that it will be possible to do same. – user1069516 Apr 30 '18 at 07:33
  • @user1069516 - That's exactly what I wrote. I don't understand what you expect, but that's what's supposed to happen: each new instance of an AX EXE server creates a separate process. To get a new process, create a new instance. Where's the problem? – Jim Mack Apr 30 '18 at 12:45
  • If I instanciate several times a class in my AX EXE, I have only one process in task manager. The goal of my ax exe is to perform simultaneously some tasks. My windows service creates a thread, and in this thread a new instance of ax is created as Altova_com AX so I expected that each instanciating creates one process and it's not the case. But I don't know if Altova_com is a VB6 component... – user1069516 Apr 30 '18 at 14:45
  • @user1069516 - Are you saying that the instancing takes place *within* the AX EXE? That's not what I'd expect. I would expect that a separate program creates multiple instances of the class(es) in your server EXE. – Jim Mack Apr 30 '18 at 18:24
  • @JimMack If I understand what you are saying, it's true if the Instancing property of the ActiveX EXE is set to SingleUse. If it is set to MultiUse, creating an instance (i.e. `Set myRef = New myActiveXEXE`) in an app only fires up a new process if there isn't one already running. Default is MultiUse. – BobRodes May 03 '18 at 18:32
  • @BobRodes - True, which is why I pressed the OP to let us know how he'd set that property. – Jim Mack May 03 '18 at 21:43
  • @JimMack So you have. I guess OP didn't understand what you meant. – BobRodes May 03 '18 at 22:00