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#
  4. Checking the fail status of windows service

Checking the fail status of windows service

Scheduled Pinned Locked Moved C#
6 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.
  • G Offline
    G Offline
    gottimukkala
    wrote on last edited by
    #1

    Hi How can we check the failure of windows service programatically. I have a windows service that elapses every 5 minutes and I need to check if the service is failed then restart it automatically in my code. I googled but I couldnt find the Failed Status for the windows service. Any ideas please!

    D J 2 Replies Last reply
    0
    • G gottimukkala

      Hi How can we check the failure of windows service programatically. I have a windows service that elapses every 5 minutes and I need to check if the service is failed then restart it automatically in my code. I googled but I couldnt find the Failed Status for the windows service. Any ideas please!

      D Offline
      D Offline
      dan sh
      wrote on last edited by
      #2

      I take failure as your service breaks ie exception. Correct me if I am wrong. If this is the case, then you need to rethink. An application that breaks every 5 minutes is not desirable.

      जय हिंद

      1 Reply Last reply
      0
      • G gottimukkala

        Hi How can we check the failure of windows service programatically. I have a windows service that elapses every 5 minutes and I need to check if the service is failed then restart it automatically in my code. I googled but I couldnt find the Failed Status for the windows service. Any ideas please!

        J Offline
        J Offline
        Jimmanuel
        wrote on last edited by
        #3

        The ServiceController[^] allows you to Start, Stop and check the running status of services.

        :Badger:

        D 1 Reply Last reply
        0
        • J Jimmanuel

          The ServiceController[^] allows you to Start, Stop and check the running status of services.

          :Badger:

          D Offline
          D Offline
          dan sh
          wrote on last edited by
          #4

          But that will work only if the service does not "fails". Isn't it?

          जय हिंद

          J 1 Reply Last reply
          0
          • D dan sh

            But that will work only if the service does not "fails". Isn't it?

            जय हिंद

            J Offline
            J Offline
            Jimmanuel
            wrote on last edited by
            #5

            That depends on what "fails" means. I took it to mean "crashes" in which case this will allow the OP to restart the service. If it means something else then no, this probably isn't very helpful. :)

            :Badger:

            D 1 Reply Last reply
            0
            • J Jimmanuel

              That depends on what "fails" means. I took it to mean "crashes" in which case this will allow the OP to restart the service. If it means something else then no, this probably isn't very helpful. :)

              :Badger:

              D Offline
              D Offline
              dan sh
              wrote on last edited by
              #6

              I took it to mean "exception" and I guess "crashes" is referring to that only. That is why I asked, will this works even if the service encounters an exception(crash).

              जय हिंद

              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