Quote Originally Posted by sotoasty View Post
Why not have a "Communication" class and a "Query" class. Have the communtication Class run the DB query on a separate thread, and in the meantime it can send the keep-alive. When the Query class is done, have the communication class get the data from the query class and send the data.

That way you have only one way to send the data/responses.
Proposal; I can hopefully split off the DB query to a worker thread and make the main thread Join(25000) it in a limited loop. When the db thread terminates it should have delivered an answer.. If Join returns false then the db worker is still executing so I can send the keepalive and go back to Joining.. Do that up to 10 times, then drop the socket.. I'm marginally concerned that by putting the thread into a loop while it sleeps the time for the Join() ties it up.. though I'm struggling to envisage a way to avoid doing this..