G
Guest
Hi...
Following the samples online, we implemented a windows service in .Net.
Like most services, there's a worker thread actually doing stuff in the
background. The problem we've run into is how to get the service to exit
when the worker thread has a fatal error *and* get the SCM to invoke the
auto-restart configuration?
The worker thread can error out while the parent thread in the server
process chugs along. We can set the exit code for the service in the worker
thread and then a) call this.Stop() or b) instantiate a ServiceController,
look ourselves up and call Stop(), or c) pull in the win32 dll and make an
unmanaged call to invoke stop. We can get the service to stop, but the
auto-restart configuration doesn't seem to kick in.
Reading old NT/Windows Services docs from win32, there is a line saying that
restart actions are taken *if the SCM wasn't called to Stop() the service*
i.e. only if the process dies a natural death.
So how does one get a .Net windows service just to die when the worker
thread dies?
Thanks
Mark
Following the samples online, we implemented a windows service in .Net.
Like most services, there's a worker thread actually doing stuff in the
background. The problem we've run into is how to get the service to exit
when the worker thread has a fatal error *and* get the SCM to invoke the
auto-restart configuration?
The worker thread can error out while the parent thread in the server
process chugs along. We can set the exit code for the service in the worker
thread and then a) call this.Stop() or b) instantiate a ServiceController,
look ourselves up and call Stop(), or c) pull in the win32 dll and make an
unmanaged call to invoke stop. We can get the service to stop, but the
auto-restart configuration doesn't seem to kick in.
Reading old NT/Windows Services docs from win32, there is a line saying that
restart actions are taken *if the SCM wasn't called to Stop() the service*
i.e. only if the process dies a natural death.
So how does one get a .Net windows service just to die when the worker
thread dies?
Thanks
Mark