Avatar of ol muser
ol muser
Flag for United States of America asked on

afxbeginthread - starting and stopping

I have a multithreading application in which I start a worker thread using AfxBeginThread to get a count( X). The thread runs a stored proc to get the count and display in the application. Right now the thread automatically ends when the controlling function ends. X might change during the life of the application and so I would like to keep the thread running in the backgroud, run the stored proc at regular intervals, say, every, 5 min so I could update the count display.  What is the best practice regarding this (I am considering using a sleeper function that wakes up every 5 min) and how do I gracefully shutdown the thread when the application goes down? Or does the worker thread automatically go down if the app is shutting down. Pls respond with actual function calls you may use.
Visual C++.NET

Avatar of undefined
Last Comment

8/22/2022 - Mon

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Your help has saved me hundreds of hours of internet surfing.