A
Alphamacaroon
All,
Does .NET support the concept of "custom" blocks?
I'd like to implement some performance profiling code into an app I'm
creating and I thought it would be really cool if you could do
something like:
profile("ProfileName") // Starts a timer
{
MyFunction1();
MyFunction2();
} // Ends a timer and writes it to a log
The concept would be to allow me to surround a group of code with a
custom block and be able to stop and start a timer based upon when it
entered and exited the block.
I know this could easily be accomplished by just adding a function
before and after, but the block would be much more elegant. Also it
would allow you to nicely accomplish the timer if for example the
second line of code (MyFunction2()) returned a value.
Can this be done?
-alpha
Does .NET support the concept of "custom" blocks?
I'd like to implement some performance profiling code into an app I'm
creating and I thought it would be really cool if you could do
something like:
profile("ProfileName") // Starts a timer
{
MyFunction1();
MyFunction2();
} // Ends a timer and writes it to a log
The concept would be to allow me to surround a group of code with a
custom block and be able to stop and start a timer based upon when it
entered and exited the block.
I know this could easily be accomplished by just adding a function
before and after, but the block would be much more elegant. Also it
would allow you to nicely accomplish the timer if for example the
second line of code (MyFunction2()) returned a value.
Can this be done?
-alpha