I have a Windows Service which is basically accessing a mailbox and reading the emails. I am trying to figure out the best way to check the mailbox every x seconds.
One method is to just call Thread.Sleep, then call the Start Method again, e.g.
protected override void OnStart(string[] args)
{
// get config settings
CheckMailbox();
}
public void CheckMailbox()
{
int x = 5000;
// do stuff
Thread.Sleep(x);
CheckMailbox();
}
Not sure if this is the best way to go about it. To then further explore this, I understand that you can call a Windows Service by exposing the Service via WCF. In this case, if a web application called the Process to start, there would be conflicting Threads am I correct? How would I then deal with that? Would I have to create a new thread each time and put it in a queue?