Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. How to keep my server alive

How to keep my server alive

Scheduled Pinned Locked Moved C / C++ / MFC
comsysadminjsonperformancetutorial
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    Bill Wilson
    wrote on last edited by
    #1

    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.

    R A 2 Replies Last reply
    0
    • B Bill Wilson

      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.

      R Offline
      R Offline
      Ramu Pulipati
      wrote on last edited by
      #2

      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

      1 Reply Last reply
      0
      • B Bill Wilson

        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.

        A Offline
        A Offline
        A A 0
        wrote on last edited by
        #3

        Do you have control over the local COM server, if so why don't you just declare it as a singleton?

        B 1 Reply Last reply
        0
        • A A A 0

          Do you have control over the local COM server, if so why don't you just declare it as a singleton?

          B Offline
          B Offline
          Bill Wilson
          wrote on last edited by
          #4

          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.

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups