have variable that all dlls used by C# program can access?

  • Thread starter Thread starter Les Caudle
  • Start date Start date
L

Les Caudle

With the Thread.AllocateNamedDataSlot("aVarName") it is possible to create a
slot that only a thread can access. A child thread cannot.

Is there a way to create a data variable that ANY thread of the main process
(whether a referenced dll or code in the main program) can read and write to?
 
Hi Les,

The most accesible a variable can be is being a static member of a class, I
think.

Cheers,
 
Les,
You could use AppDomain.SetData & AppDomain.GetData for application domain
level data.

However I would think a class with static members (variations of the
Singleton Pattern) would be a 'cleaner' more OOP/encapsulated method.

Another option is the Registry Patten (based on the Singleton Pattern) which
is effectively what the AppDomain.SetData & AppDomain.GetData are.

http://www.martinfowler.com/eaaCatalog/registry.html

Hope this helps
Jay
 
Back
Top