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. Database & SysAdmin
  3. System Admin
  4. Question on services and SCM...

Question on services and SCM...

Scheduled Pinned Locked Moved System Admin
questiontutorial
5 Posts 2 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.
  • C Offline
    C Offline
    CherezZaboro
    wrote on last edited by
    #1

    When you order a service to stop when it's really busy with something and may take to stop like 5-10 minutes for example, will system kill it anyway on its own at some point or it will wait infinitely for it to stop? :wtf: Same q for the all other requests.

    R 1 Reply Last reply
    0
    • C CherezZaboro

      When you order a service to stop when it's really busy with something and may take to stop like 5-10 minutes for example, will system kill it anyway on its own at some point or it will wait infinitely for it to stop? :wtf: Same q for the all other requests.

      R Offline
      R Offline
      Robert Little
      wrote on last edited by
      #2

      inner wrote: may take to stop like 5-10 minutes for example, will system kill it anyway on its own at some point or it will wait infinitely for it to stop? Depends on how you write the service. You must report the status of your service at regular intervals to inform the SCM of your state. When you receive a request to stop, you set the service status to stopping. Then every few seconds you update the SCM and let it know you are still stopping. If the SCM does not receive an update within a reasonable amount of time it will assume you have stopped responding. The same would be true during startup, pause, and continue. Just provide updated every few seconds. If you need to perform a really long operation that cannot be broken down into smaller portions then run that work in a seperate thread. Then in the main thread you wait a limited time for the worker thread to complete. If it does not finish you report your status and then wait again. --

      "The money power of the country will endeavor to prolong its rule by preying upon the prejudices of the people until all wealth is concentrated in a few hands and the Republic destroyed." -- Abraham Lincoln

      C 2 Replies Last reply
      0
      • R Robert Little

        inner wrote: may take to stop like 5-10 minutes for example, will system kill it anyway on its own at some point or it will wait infinitely for it to stop? Depends on how you write the service. You must report the status of your service at regular intervals to inform the SCM of your state. When you receive a request to stop, you set the service status to stopping. Then every few seconds you update the SCM and let it know you are still stopping. If the SCM does not receive an update within a reasonable amount of time it will assume you have stopped responding. The same would be true during startup, pause, and continue. Just provide updated every few seconds. If you need to perform a really long operation that cannot be broken down into smaller portions then run that work in a seperate thread. Then in the main thread you wait a limited time for the worker thread to complete. If it does not finish you report your status and then wait again. --

        "The money power of the country will endeavor to prolong its rule by preying upon the prejudices of the people until all wealth is concentrated in a few hands and the Republic destroyed." -- Abraham Lincoln

        C Offline
        C Offline
        CherezZaboro
        wrote on last edited by
        #3

        Hmmmm... Ok. I always thought that SCM makes calls to a service and not the other wayt around. How do you send anything back from service to SCM? Even would be a lot better is you know how to do that in C# service. Thanks a lot.

        R 1 Reply Last reply
        0
        • R Robert Little

          inner wrote: may take to stop like 5-10 minutes for example, will system kill it anyway on its own at some point or it will wait infinitely for it to stop? Depends on how you write the service. You must report the status of your service at regular intervals to inform the SCM of your state. When you receive a request to stop, you set the service status to stopping. Then every few seconds you update the SCM and let it know you are still stopping. If the SCM does not receive an update within a reasonable amount of time it will assume you have stopped responding. The same would be true during startup, pause, and continue. Just provide updated every few seconds. If you need to perform a really long operation that cannot be broken down into smaller portions then run that work in a seperate thread. Then in the main thread you wait a limited time for the worker thread to complete. If it does not finish you report your status and then wait again. --

          "The money power of the country will endeavor to prolong its rule by preying upon the prejudices of the people until all wealth is concentrated in a few hands and the Republic destroyed." -- Abraham Lincoln

          C Offline
          C Offline
          CherezZaboro
          wrote on last edited by
          #4

          Also do you know how ro "register" or "re-register" a "source" to "log" for event logging? I keep getting this "The source 'MyService' is not registered in log 'Application'. (It is registered in log 'MyServiceLog'.) " The Source and Log properties must be matched, or you may set Log to the empty string, and it will automatically be matched to the Source property." exception after I tried to change the log to standard "application".

          1 Reply Last reply
          0
          • C CherezZaboro

            Hmmmm... Ok. I always thought that SCM makes calls to a service and not the other wayt around. How do you send anything back from service to SCM? Even would be a lot better is you know how to do that in C# service. Thanks a lot.

            R Offline
            R Offline
            Robert Little
            wrote on last edited by
            #5

            Well using C# I am not sure. I've seen C# and that is about it. In C++ using Win32 you would do something like this. SetServiceStatus(m_tSvcStatusHandle, &m_tSvcStatus); Do a search on MSDN for SetServiceStatus. SetServiceStatus[^] --

            "The money power of the country will endeavor to prolong its rule by preying upon the prejudices of the people until all wealth is concentrated in a few hands and the Republic destroyed." -- Abraham Lincoln

            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