Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: Stopping a Windows service when the secondary thread terminates


This question is answered.


Permlink Replies: 1 - Last Post: Jan 22, 2018 9:32 AM Last Post By: Remy Lebeau (Te...
Jayme Jeffman

Posts: 20
Registered: 3/2/98
Stopping a Windows service when the secondary thread terminates  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 22, 2018 5:11 AM
Hello,

I apologise for posting at this forum if it is not the right place for this question.

I have made a Windows Service which starts a secondary thread as suggested as a good practice.

The secondary thread might be terminated due to database permanent connection failures, other errors or even if it is requested to stop.

I would like to know how can I tell the main thread (Service) to terminate when the secondary thread terminates.

Thank you very much.

Best regards.

Jayme Jeffman
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: Stopping a Windows service when the secondary thread terminates
Correct
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 22, 2018 9:32 AM   in response to: Jayme Jeffman in response to: Jayme Jeffman
Jayme Jeffman wrote:

I would like to know how can I tell the main thread (Service) to
terminate when the secondary thread terminates.

In the OnTerminate event of the secondary thread, call the service's
global Controller() function to send a SERVICE_CONTROL_STOP request to
the service.

--
Remy Lebeau (TeamB)
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02