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 6681237
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T04:34:02+00:00 2026-05-26T04:34:02+00:00

I have a good old fashioned windows service (inheriting from System.ServiceProcess.ServiceBase), to which I

  • 0

I have a good old fashioned windows service (inheriting from System.ServiceProcess.ServiceBase), to which I added a component (implementing IComponent) by this.components.Add(new MyStuff());
However MyStuff’s Disposable() doesn’t run if I shut down the exe from Task Manager.

Possible suspects:

  • Nothing runs on “End Process”. If so, how do I clean up after myself (e.g. kill started processes?)
  • For testing purposes I start my service with

    var service = new MyService();
    service.Run();
    Thread.Wait(Timeout.Infinite);

    instead of ServiceBase.Run(new []{new MyService()}); can that be the problem?

  • ServiceBase doesn’t clean up automaticly. If so, what should I do?

Please help!

Additional info: I’m trying to shut down other exes I’ve started from my service using Process.Start(…), so if there’s a way to make them auto-shutdown (child process?) that would be fine too.

  • 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-26T04:34:02+00:00Added an answer on May 26, 2026 at 4:34 am

    My typical way of having children detect the death of a parent:

    • During parent startup, generate a nice, long, random name
    • Also during startup, obtain a named mutex with this name, and keep that held locked for the lifetime of the parent.
    • When starting a child process, pass the long random name as a parameter
    • In the children, dedicate a thread that attempts to obtain the same named mutex.
    • If the child ever obtains the mutex, the parent process must have died – so the child should exit also

    By using a random name for the mutex, you ensure that a new hierarchy can be constructed even whilst the older parent/child hierarchy is in the process of being shut down.

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

Sidebar

Related Questions

I have a windows service. If I start it from the debugger I want
Does PHP have any standard function(s) to convert Unicode strings to plain, good old-fashioned
I have a footer, and want to do the good old fashioned Keep the
I have a string: hello good old world and i want to upper case
We're building a PHP app based on Good old codeigniter framework and have run
Say I have the good old person/group/membership relationship class Person(models.Model): name = models.CharField(max_length=128) def
The Scenario I have an application where we took the good old query string
In good old MFC, the DDX routines would have built in validation for form
I have a good friend (my old college roommate, actually), who critiques my personal
does anyone have good links or tips on best practices concerning migrating from ASP.NET

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.