How to run application continously?
<p>Any idea how to run application continuosly? I tried follow suggestion from this link <a href="http://stackoverflow.com/questions/593273/run-application-continuously">Run Application Continuously</a> but unsuccessfully. It might be coz of my coding but don't know how to amend it. Someone suggest me to use Windows Service, but I don't want to use it at this moment coz i want to learn basic first like above link. Hope someone can advise/guide me how to amend my coding. Kindly refer below for my coding.
Thanks!!</p>

<p>Program.cs:-</p>

<pre><code>    static int exitFlag = 0;
    private static int m_intErrCounter = 0;
    static int Main(string[] args)
    {
        int retValue = 0;

        while (exitFlag != 0)
        {
            retValue = CounterApp();

        }
        //return retValue;
        return 0;

    }

    public static int CounterApp()
    {
        string machineName = ConfigurationManager.AppSettings["MachineName"];
        string categoryName = ConfigurationManager.AppSettings["CategoryName"];
        string counterName = ConfigurationManager.AppSettings["CounterName"];
        string instanceName = ConfigurationManager.AppSettings["InstanceName"];
        PerformanceCounterCategory pcc;
        PerformanceCounter[] counters;
        m_intErrCounter = 0;

        try
        {
            // Create the appropriate PerformanceCounterCategory object.
            if (machineName.Length &gt; 0 &amp;&amp; instanceName.Length &gt; 0)
            {
                pcc = new PerformanceCounterCategory(categoryName, machineName);
                counters = pcc.GetCounters(instanceName);
            }
            else
            {
                pcc = new PerformanceCounterCategory(categoryName);
                counters = pcc.GetCounters();
            }

        }
        catch (Exception)
        {
            Console.WriteLine("Couldn't found the application");
            Console.ReadKey();
            return 0;
        }

        String strBody = String.Empty;
        if (counters.Length != 0)
        {

            for (int objX = 0; objX &lt; counters.Length; objX++)
            {
                if ((counters[objX].CounterName == counterName) &amp;&amp; (counters[objX].RawValue &gt; 0))
                {
                    strBody = "Error occured at " + counters[objX].InstanceName.ToString();
                    strBody += " : " + counters[objX].CounterName.ToString() + " thrown " + counters[objX].RawValue.ToString() + " times.";
                    m_intErrCounter++;
                    exitFlag = 1;
                }
            }
        }
        if (m_intErrCounter &gt; 0)
        {
            SendMail("Notification Email", strBody);
            exitFlag = 1;
        }            
        return exitFlag;
    }

    private static void SendMail(String strSubj, String strBody)
    {
        MailMessage Message = new MailMessage();
        Message.From = new MailAddress("email@company.com.my");
        Message.To.Add(new MailAddress("email@company.com.my"));
        Message.Subject = strSubj;
        Message.Body = strBody;

        SmtpClient client = new SmtpClient("smtp.company.com.my", 25);

        client.EnableSsl = false;
        client.Credentials = new System.Net.NetworkCredential("email@company.com.my", "Passw0rd");

        client.Send(Message);
        Console.WriteLine("Success Send Message");
    }
</code></pre>
