Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 218405
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T18:44:51+00:00 2026-05-11T18:44:51+00:00

I have a VB.NET Windows Service that I wrote and it works fine. In

  • 0

I have a VB.NET Windows Service that I wrote and it works fine. In VB.NET there is an overrideable method called OnStop() that gets called when the service is stopped. However, it appears it only gets stopped if someone actually stops the service from the Services MMC Console Window.

My question is, is there an event or an overridable method that gets called whenever the service stops, regardless of how it got stopped (e.g. Computer reboots, Exception occured and shut down service, etc….)?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T18:44:52+00:00Added an answer on May 11, 2026 at 6:44 pm

    There is no one event to handle all of those events. Most of the events you listed can be dealt with on an individual basis.

    • OnShutdown can overriden to deal with non-sudden power events (user shutdown, reboot, etc …)
    • Application.UnhandledException can be used for unhandled exceptions

    Note that you cannot depend on these events firing 100% of the time. There are situations where each event will fail to run. For instance, the power related events won’t fire if I walk up and rip out the power cord. Your code must account for the service shutting down without any prior notification.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an ASP.NET MVC website that works in tandem with a Windows Service
I have a .NET Windows serivce protected with {smartassembly} which works fine, except that
I have a .NET Windows service and a .NET Web Application that I would
I have a very simple windows Service that is developed in vb.net 2008. When
I have an ASP.NET web service that I can access via a windows program
I have a windows forms client that consumes an ASP.net web service. It's my
I wrote a VB.NET windows service and I'd like to know if there is
I have a multithreaded .NET Windows Service that hangs intermittently -- maybe once every
I have developed a .NET Windows Service (in VS2010) that needs to: Access shared
We have about 7 app servers running .NET windows services that ping a single

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.