Dustin Davis
Dustin Davis

Reputation: 14605

Adding ambient data to the thread

I want to add custom data to the thread. For example, ambient transaction scope are stored in the thread as well as identity info. I would like to have my own ambient data available. Is there a way to do this OTB or would there be a lot of work that just isnt worth it?

Let's say that I have a using

using(var x = new MyDataClass())
{
 SomeMethod();
}

In SomeMethod() I want to have access to the instance of MyDataClass that was declared in the calling method.

Upvotes: 1

Views: 410

Answers (1)

Oded
Oded

Reputation: 499402

Sounds like you are looking for ThreadStaticAttribute, unless I completely misunderstood the question.

This article - Thread Local Storage: Thread-Relative Static Fields and Data Slots, may be of interest.

Upvotes: 3

Related Questions