1
votes

I have a C# Console application that is executed using the windows server 2008 task scheduler, however when an exception occurs inside the application I still get "Task Completed" in the event log. I would like to trigger a task failed when an exception occurs.

1

1 Answers

2
votes

You should make your console application return an int different from 0:

class Program {
    static int Main(string[] args) {
        try {
            do_stuff();
            return 0; 
        } catch (MyException exc) {
            return 1;
        }
    }
}