I have been debeloping in C++ Builder.
I want to develop an email alerter program for windows machine. This program will start at startup and every 5 seconds will ask the mail server for the new messages. If new message comes the email alerter program will start an animation.
I want it to run in daemon mode (work in background and listening new messages), but I have no idea how to do this. Maybe with an endless cycle? I think it's not very good idea.

Do you have any other idea how to develop a program to run in daemon mode?

Thank you