Running an application continuously
Your loop doesn't work because the initial value for exitFlag variable (which is used as condition for the loop) is zero, and it is only being set to 1 under a special set of circumstances which apparently doesn't happen when you run an application.

If you really want to loop forever and only quit application when it fails your loop, have your function return 1 unless it fails. It should look something like this:

int Main(string[] args)
{
    while (CounterApp() != 0)
    {
    }
    return 0;
}

public static int CounterApp()
{
    // do some stuff

    try
    {
        // do some stuff that might fail
    }
    catch (Exception)
    {
        return 0;
    }

    // do some other stuff

    return 1;
}