I've created a create a console app that would:
- Call a method to check an email account (I've done this step)
- Convert the attachment to pdf (I've done this step)
- Then once the conversion is complete wait 30 seconds
- Repeat the previous 3 steps continuously
I've done Step 1 and 2 int the ProcessMailMessages() method. The following code works but I want to know if I am on the right track or is there a better way to poll a email client?
private static int secondsToWait = 30 * 1000;
static void Main(string[] args)
{
bool run = true;
do
{
try
{
Task theTask = ProcessEmailTaskAsync();
theTask.Wait();
}
catch (Exception e)
{
Debug.WriteLine("<p>Error in Client</p> <p>Exception</p> <p>" + e.Message + "</p><p>" + e.StackTrace + "</p> ");
}
GC.Collect();
} while (run);
}
static async Task ProcessEmailTaskAsync()
{
var result = await EmailTaskAsync();
}
static async Task<int> EmailTaskAsync()
{
await ProcessMailMessages();
await Task.Delay(secondsToWait);
return 1;
}
static async Task ProcessMailMessages()
{
...............................................................................
}
CG.Collect();
? – Trevor Pilley Nov 15 '12 at 16:50