How to keep my server alive
-
I have a local COM server that wraps a 3rd party API. The API contains open and close calls that require significant time. Any number of interactive processes will create and instance of the COM object. So, I set up the local server to perform the open when the app starts and close when the app exits. This allows users to connect, perform calcualtions and disconnect from the COM object without the overhead of the open and close calls. This produced a performance improvment of about 4000:1. This solution is only effective if the users connect to the same local server. This is my registration code:
hRes = \_Module.RegisterClassObjects(CLSCTX\_LOCAL\_SERVER, REGCLS\_MULTI\_SEPARATE | REGCLS\_SUSPENDED);
From my reading of MSDN, this looks like I should get one and only one .exe running. What seems to happen is somewhat different. I created a test harness to try it out. I can run many instances of the test harness, while only one instance of the .exe is launched. So far, so good. This is exactly what I want. If I then run the production application while the test harness is running, I get a second instance of the local . I can run multiple instances of the production program without any more instances being launched. The production app uses CoCreateInstance to acquire and interface and releases it when finished. Ideally, I would like to start the local server independentaly of the any application that uses it and have client apps use the already running .exe. I tried creating an instance of the COM object in the _twinMain of the local server, but that had no effect. Any ideas? Suggestions? Solutions? Bad advice? Thanks in advance for any responses.
-
I have a local COM server that wraps a 3rd party API. The API contains open and close calls that require significant time. Any number of interactive processes will create and instance of the COM object. So, I set up the local server to perform the open when the app starts and close when the app exits. This allows users to connect, perform calcualtions and disconnect from the COM object without the overhead of the open and close calls. This produced a performance improvment of about 4000:1. This solution is only effective if the users connect to the same local server. This is my registration code:
hRes = \_Module.RegisterClassObjects(CLSCTX\_LOCAL\_SERVER, REGCLS\_MULTI\_SEPARATE | REGCLS\_SUSPENDED);
From my reading of MSDN, this looks like I should get one and only one .exe running. What seems to happen is somewhat different. I created a test harness to try it out. I can run many instances of the test harness, while only one instance of the .exe is launched. So far, so good. This is exactly what I want. If I then run the production application while the test harness is running, I get a second instance of the local . I can run multiple instances of the production program without any more instances being launched. The production app uses CoCreateInstance to acquire and interface and releases it when finished. Ideally, I would like to start the local server independentaly of the any application that uses it and have client apps use the already running .exe. I tried creating an instance of the COM object in the _twinMain of the local server, but that had no effect. Any ideas? Suggestions? Solutions? Bad advice? Thanks in advance for any responses.
Couple of bluffs here...;) Go for 'Win32 Service' instead of 'LocalServer'. Will solve all the problems! Just to keep LocalServer running, Fool it! Set the event (hEventShutdown) manually when you want to close the app and dont set the it on CExeModule::Unlock(). I'm not sure this is the correct approach. Thanks, Ramu
-
I have a local COM server that wraps a 3rd party API. The API contains open and close calls that require significant time. Any number of interactive processes will create and instance of the COM object. So, I set up the local server to perform the open when the app starts and close when the app exits. This allows users to connect, perform calcualtions and disconnect from the COM object without the overhead of the open and close calls. This produced a performance improvment of about 4000:1. This solution is only effective if the users connect to the same local server. This is my registration code:
hRes = \_Module.RegisterClassObjects(CLSCTX\_LOCAL\_SERVER, REGCLS\_MULTI\_SEPARATE | REGCLS\_SUSPENDED);
From my reading of MSDN, this looks like I should get one and only one .exe running. What seems to happen is somewhat different. I created a test harness to try it out. I can run many instances of the test harness, while only one instance of the .exe is launched. So far, so good. This is exactly what I want. If I then run the production application while the test harness is running, I get a second instance of the local . I can run multiple instances of the production program without any more instances being launched. The production app uses CoCreateInstance to acquire and interface and releases it when finished. Ideally, I would like to start the local server independentaly of the any application that uses it and have client apps use the already running .exe. I tried creating an instance of the COM object in the _twinMain of the local server, but that had no effect. Any ideas? Suggestions? Solutions? Bad advice? Thanks in advance for any responses.
-
Do you have control over the local COM server, if so why don't you just declare it as a singleton?
Thanks for the reply. I'm not familiar with singleton's. Can you refer me to a source? I looked up singleton in MSDN, what I found didn't seem to apply.