locked
Win service in shutdown windows RRS feed

  • Question

  • Hi,

       I need some stuff like disconnect from server in win service, I add this in the STOP function, but seems like when windows shutdown this function not been called.

    How when service will know if windows shutting down, or service going down to do its cleanup before.

    Thanks,

    Saturday, April 20, 2013 3:49 PM

Answers

  • This what your looking for?

    protected override void OnShutdown()
    {
        //your code here
        base.OnShutdown();
    }
    
    

    You can also override the sessionchanged event.

    • Proposed as answer by Mike Feng Monday, April 22, 2013 9:02 AM
    • Marked as answer by Mike Feng Saturday, May 4, 2013 1:31 PM
    Saturday, April 20, 2013 9:31 PM

All replies

  • This what your looking for?

    protected override void OnShutdown()
    {
        //your code here
        base.OnShutdown();
    }
    
    

    You can also override the sessionchanged event.

    • Proposed as answer by Mike Feng Monday, April 22, 2013 9:02 AM
    • Marked as answer by Mike Feng Saturday, May 4, 2013 1:31 PM
    Saturday, April 20, 2013 9:31 PM
  • Be aware that this forum is for the GUI Windows Forms, ask Windows Service question in the General forum of your program language.

    http://social.msdn.microsoft.com/Forums/en-US/category/vslanguages


    Success
    Cor

    Monday, April 22, 2013 10:31 AM
  • Hi There,
    Do you have any update?
    I have temporarily closed this thread. If it doesn't help you, please feel free to follow up.
    Thanks.
    Best regards,

    Mike Feng
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Saturday, May 4, 2013 1:31 PM
  • Steven_Schultz answer works (I marked it as an answer)
    Saturday, May 4, 2013 2:08 PM