I would like to have a thread running in background which will check connection to some server with given time interval. For example for every 5 seconds.
I don't know if there is a good "desing pattern" for this? If I remember corretly, I've read somewehere that sleeping thread in its execute method is not good. But I might be wrong.
Also, I could use normal TThread class or OTL threading library.
Any ideas?
Thanks.
You could use an event and implement the Execute
method of the TThread
descendant by a loop with WaitForSingleObject
waiting for the event, specifying the timeout. That way you can wake the thread up immediately when needed, e.g. when terminating.