Polling a email using async await c#
<p>I'm creating a console app that would:</p>

<ol>
<li>Call a method to check an email account(I've done this step)</li>
<li>Convert the attachemnt to pdf(I've done this step)</li>
<li>Then once the conversion is complete wait 30 seconds</li>
<li>Repeat the previous 3 steps continously</li>
</ol>

<p>I've done steps 1) and 2) in the <code>ProcessMailMessages()</code> 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?</p>

<pre><code>    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("&lt;p&gt;Error in Client&lt;/p&gt; &lt;p&gt;Exception&lt;/p&gt; &lt;p&gt;" + e.Message + "&lt;/p&gt;&lt;p&gt;" + e.StackTrace + "&lt;/p&gt; ");
            }
            GC.Collect();

        } while (run);

    }

    static async Task ProcessEmailTaskAsync()
    {
        var result = await EmailTaskAsync();
    }

    static async Task&lt;int&gt; EmailTaskAsync()
    {
        await ProcessMailMessages();
        await Task.Delay(secondsToWait);
        return 1;
    }

    static async Task ProcessMailMessages()
    {
        ...............................................................................
    }
</code></pre>
