We have some developers in house that believe it is best practice to use exception handing as flow control, as well as, thinking that catching and re-throwing exceptions is effective error handling.  In an effort to educated, I attempted to come up with a simple sample to demonstrate to them the negative effects of doing so.  The code sample below is what I came up with.  It consistently demonstrates that there is a penalty for gratuitous usage of try/catch blocks; but the effect is much greater than I had anticipated.  I can't help but think I've done something very wrong in this sample.  I would appreciate any suggestions of improvement.In this sample, I am comparing the cost of catching and re-throwing an exception with just allowing the exception to bubble up.  I needed to execute the methods in parallel to avoid waiting days for the code to execute on high values.    static void Main(string[] args)    {        TimeSpan ts1 = new TimeSpan();        TimeSpan ts2 = new TimeSpan();        List<Task> tasks = new List<Task>();        for (int i = 0; i < 100; ++i)        {            Task a = new Task(() =>            {                Stopwatch watch1 = new Stopwatch();                watch1.Start();                function1(function2);                watch1.Stop();                ts1 += watch1.Elapsed;            });            a.Start();            tasks.Add(a);            Task b = new Task(() =>            {                Stopwatch watch2 = new Stopwatch();                watch2.Start();                function1(function3);                watch2.Stop();                ts2 += watch2.Elapsed;            });            b.Start();            tasks.Add(b);        }        while (!tasks.All(t => t.IsCompleted)) ;        Console.WriteLine(Watch1:  + ts1);        Console.WriteLine(Watch2:  + ts2);        Console.ReadLine();    }    static void function1(Action action)    {        try        {            action();        }        catch        {        }    }    static void function2()    {        try        {            int.Parse(null);        }        catch        {            throw;        }    }    static void function3()    {        int.Parse(null);    }      
Is This a Sufficient Demonstration of the Effects of Exception Handling
c#;exception handling
The while loop you are using is impacting performance.  Sleep that check a bit beforehand to give your scenarios some time to think.  do { Thread.Sleep(3000); } while (!tasks.All(t => t.IsCompleted));You may want to suggest some best practices reading to your team, throwing an exception should be reserved for an exceptional circumstance.  Use of the throw for rethrowing an exception is correct to keep the stack trace information complete, but again, should be seldom and when they do finally bubble up to the top, the exception information should be captured in a way that they are not just ignored.http://www.codeproject.com/KB/architecture/exceptionbestpractices.aspxhttps://stackoverflow.com/questions/409563/best-practices-for-exception-management-in-java-or-chttp://www.codethinked.com/how-do-you-deal-with-exceptions