I am calling from one piece of my code through several layers of 3rd party code, and the call surfaces back into my code at some point by calling some code I've written.
In other words, the code call chain looks like this:
My code #1 --> 3rd party code --> My code #2
Unfortunately, nothing I pass to the 3rd party code is given to that second piece of code so I have nothing to tie the first piece and the second piece together, except for the fact that the code runs on the same thread.
So I was wondering if simply using [ThreadStatic]
on a static field on a class would be a viable solution to this?
Since the code also runs in a web application, I cannot just use a static field for this, since the value I need access to (an object) is different for each user/session.
ie. I would do something like this:
internal static class DataHolder
{
[ThreadStatic]
internal static ClassName FieldName;
}
Are there other solutions to this?