I'm not looking for a way to associate values with a thread using the 'SetData' method.
I need to store some kind of data that will only exist during the scope of a calling method, could be the immediate parent or any other call that is made down on the stack. For example:
void SomeMethod()
{
string someInfo = "someInfo";
SomeOtherMethod();
object data = GetDataOnCurrentScope("someKey");
}
void SomeOtherMethod()
{
SetDataOnParentScope("someKey", somevalue);
}
In this case both the 'someInfo' local variable and the data set with the "someKey" key will disapear after 'SomeMethod' returns. Is something like this possible? This may go against the rules of a stack, but who knows if someone has an idea...
obs: Currently, I guess the only way is to have a compiler declare a reference to a dictionary in the beginning of every method's call stack. That dictionary would be eligible for garbage collection when the method returns.