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.