I just realized that in some place in my code I have the return statement inside the lock and sometime outside. Which one is the best?
1)
void exampl
It doesn't make any difference; they're both translated to the same thing by the compiler.
To clarify, either is effectively translated to something with the following semantics:
T myData; Monitor.Enter(mutex) try { myData= // something } finally { Monitor.Exit(mutex); } return myData;