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.