.net - Under what context am I running in C#? -


i wondering...

when have code this:

lock (obj) { mycode.myagent(); } 

can myagent contain code recognizes running under lock block?

what about:

for (int i=0;i<5;i++) { mycode.myagent(); } 

can myagent contain code recognizes running under loop block ?

the same question can asked using blocks, unsafe code , etc... - idea...

is possible in c#?

this theoretical question, i'm not trying achieve anything... knowledge.

it isn't impossible, can use stacktrace class reference caller method , methodinfo.getmethodbody() il of method.

but you'll never reliable, just-in-time compiler's optimizer give hard time figuring out call located. method body inlining make method disappear completely. loop unrolling make impossible idea loop index. optimizer uses cpu registers store local variables , method arguments, making impossible reliable variable value.

not mention tin foil chewing effort involved in decompiling il. none of anywhere near simplicity , speed of passing argument method.


Comments

Popular posts from this blog

javascript - backbone.js Collection.add() doesn't `construct` (`initialize`) an object -

php - Get uncommon values from two or more arrays -

Adding duplicate array rows in Php -