C
Chirag
I will soon be working on a embedded device using .NET Compact
Framework where performance is a major issues. Therefore, I would like
the ability to disable exceptions at compile time. I use the below
approach to conditionally compile the "Throw" part of the exception
handling. Is there any elegent (clutter free) way to compile out the
"Try...Catch" portion. This is a concern because I believe the "Try"
statement takes a performance hit by copying the exception handler on
to the stack before actually trying the code. Any ideas?
using System.Diagnostic;
class AClass
{
[Conditional("DEBUG")]
public void DoSomeTest(object objToBeTested)
{
if(skyIsBlue & objToBeTested != null)
throw new UserException();
}
void MyMethod()
{
// only called in debug mode, same as an #if DEBUG
//#endif pair
DoSomeText();
}
}
Framework where performance is a major issues. Therefore, I would like
the ability to disable exceptions at compile time. I use the below
approach to conditionally compile the "Throw" part of the exception
handling. Is there any elegent (clutter free) way to compile out the
"Try...Catch" portion. This is a concern because I believe the "Try"
statement takes a performance hit by copying the exception handler on
to the stack before actually trying the code. Any ideas?
using System.Diagnostic;
class AClass
{
[Conditional("DEBUG")]
public void DoSomeTest(object objToBeTested)
{
if(skyIsBlue & objToBeTested != null)
throw new UserException();
}
void MyMethod()
{
// only called in debug mode, same as an #if DEBUG
//#endif pair
DoSomeText();
}
}