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. starting Windows service again on exception..

starting Windows service again on exception..

Scheduled Pinned Locked Moved C#
10 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.
  • M Offline
    M Offline
    Mubeen asim
    wrote on last edited by
    #1

    i have a windows service and when any exceptions occur then its stopping... is there any way to restart that service automatically when it is stopped...

    M 1 Reply Last reply
    0
    • M Mubeen asim

      i have a windows service and when any exceptions occur then its stopping... is there any way to restart that service automatically when it is stopped...

      M Offline
      M Offline
      musefan
      wrote on last edited by
      #2

      1. prob not the best forum 2. 5 seconds of my time found an answer on google Here is the work you could not be bothered to do yourself[^]

      Life goes very fast. Tomorrow, today is already yesterday.

      M 1 Reply Last reply
      0
      • M musefan

        1. prob not the best forum 2. 5 seconds of my time found an answer on google Here is the work you could not be bothered to do yourself[^]

        Life goes very fast. Tomorrow, today is already yesterday.

        M Offline
        M Offline
        Mubeen asim
        wrote on last edited by
        #3

        thans for that.. but is the code in the public override onstop() { //progie code } will this function execute when the service is stopped due to abnormal execution such as exception....

        M 1 Reply Last reply
        0
        • M Mubeen asim

          thans for that.. but is the code in the public override onstop() { //progie code } will this function execute when the service is stopped due to abnormal execution such as exception....

          M Offline
          M Offline
          musefan
          wrote on last edited by
          #4

          It is unlikely that any event will fire when you get an exception. Your best bet would be to handle an errors and exceptions so your service does not crash. I dont really want to suggest putting the whole service in one try/catch block and doing some restarting code in that but its your choice what approach you take

          Life goes very fast. Tomorrow, today is already yesterday.

          M 1 Reply Last reply
          0
          • M musefan

            It is unlikely that any event will fire when you get an exception. Your best bet would be to handle an errors and exceptions so your service does not crash. I dont really want to suggest putting the whole service in one try/catch block and doing some restarting code in that but its your choice what approach you take

            Life goes very fast. Tomorrow, today is already yesterday.

            M Offline
            M Offline
            Mubeen asim
            wrote on last edited by
            #5

            ok... if you are free can u tell will the service crash when the exception eccurs in the service...and i am sending the data from systems on the network to the service. and when the number of clients get more i get the exception "The IAsyncResult object was not returned" at the client side and insted of client crashing my service crashes....can i get some help with this...

            M 1 Reply Last reply
            0
            • M Mubeen asim

              ok... if you are free can u tell will the service crash when the exception eccurs in the service...and i am sending the data from systems on the network to the service. and when the number of clients get more i get the exception "The IAsyncResult object was not returned" at the client side and insted of client crashing my service crashes....can i get some help with this...

              M Offline
              M Offline
              musefan
              wrote on last edited by
              #6

              Im afraid i can not give you any detailed help on this subject but it appears that you have a problem handling your connections in your service. the service should ideally receive a request for a connection, check anything that may stop it using a new connection, and then report back to the client with a success/fail message in regards to the connection request. EDIT:

              max.4u wrote:

              will the service crash when the exception eccurs in the service...

              Yes the service will crash just like any application would if an unhandled exception is thrown

              Life goes very fast. Tomorrow, today is already yesterday.

              M 1 Reply Last reply
              0
              • M musefan

                Im afraid i can not give you any detailed help on this subject but it appears that you have a problem handling your connections in your service. the service should ideally receive a request for a connection, check anything that may stop it using a new connection, and then report back to the client with a success/fail message in regards to the connection request. EDIT:

                max.4u wrote:

                will the service crash when the exception eccurs in the service...

                Yes the service will crash just like any application would if an unhandled exception is thrown

                Life goes very fast. Tomorrow, today is already yesterday.

                M Offline
                M Offline
                Mubeen asim
                wrote on last edited by
                #7

                its ok... i wil once again review my code in the service... and do u know whats the maximum number of connections the tcp listener can handle without queing....?

                M 1 Reply Last reply
                0
                • M Mubeen asim

                  its ok... i wil once again review my code in the service... and do u know whats the maximum number of connections the tcp listener can handle without queing....?

                  M Offline
                  M Offline
                  musefan
                  wrote on last edited by
                  #8

                  It appears to vary based on the OS, i just had a quick look at this[^]

                  Life goes very fast. Tomorrow, today is already yesterday.

                  M 1 Reply Last reply
                  0
                  • M musefan

                    It appears to vary based on the OS, i just had a quick look at this[^]

                    Life goes very fast. Tomorrow, today is already yesterday.

                    M Offline
                    M Offline
                    Mubeen asim
                    wrote on last edited by
                    #9

                    thanks... and if i am not bothering you.... when i create a tcp socket and connect to the server and when the connection is established then is it regarded as the tcp connection or a socket connection..?

                    M 1 Reply Last reply
                    0
                    • M Mubeen asim

                      thanks... and if i am not bothering you.... when i create a tcp socket and connect to the server and when the connection is established then is it regarded as the tcp connection or a socket connection..?

                      M Offline
                      M Offline
                      musefan
                      wrote on last edited by
                      #10

                      Im not sure but i would say it would be both

                      Life goes very fast. Tomorrow, today is already yesterday.

                      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