Where to start the try block and what's the overhead???

  • Thread starter Thread starter Bob Rock
  • Start date Start date
B

Bob Rock

Hello,

this is something I've been asking myself for sometime ... and now I'd like
to clarify this point.
When should the try block start in a method??? What I mean is, does having
all the code instead of a smaller set of it inside a try clause add any
overhead???
What I'd like to understand is if, to be completely sure that no unhandles
exception will get to the user, I can place all the code inside a try block
and if this practice adds unnecessary overhead (memory usage, more cpu
cycles, etc.) or if having a smaller set of instructions instead of all the
code under a try has the EXACT SAME effect on resources (overhead).


Bob Rock
 
Throwing and catching exceptions is the 'costly' thing. Just trapping them
in try/catch doesn't have any discernable effect.

In general though, you should only try/catch one or a few lines of code so
you can respond to something specific and do something to correct it.

HTH,

Bill


www.devbuzz.com
www.knowdotnet.com
 
Hi Bob,

In addition to Bill, I agree as he says, once when I told the same someone
said.

I start all my procedures wit a Try and end it with a catch End Try. Just
because I send them to clients and when there is an error they can report
the error I have set in the catch block.

I had no reply on that answer.

Cor
 
Back
Top