TechTalk Genome v4.2

Context.Current Property

Gets the active Context in the calling thread.

public static IContext Current {get;}

Property Value

Returns the active Context in the calling thread.


Proxies returned by Genome are context independent, that is they do not have any Context preference. Whenever data is accessed on an unbound proxy, the context stack of the calling thread is investigated to acquire the active context as returned by Current. Thus the Context used by unbound proxies solely depends on the previous Push method calls in the same thread. Since context independent proxies are not bound to any context, they are valid even if the active Context in the calling thread is discarded - although the proxy might access different state of the same object when applied in a different Context.

In the current implementation each Thread maintains its own stack of contexts. The Context on the top of the stack is the active context in that thread. Every program block in the executing application can define alternative data access strategies by creating its custom configured context and setting it as the active context of its thread by calling the Push method. After the program block has executed the context is unloaded from the executing thread using the Pop method, thus restoring the context that was active before the program block would have been called. Alternatively a program block can decide to use the active context provided by its caller thus making the program block configurable in terms of data access strategies.

Current always uses the context stack in the calling thread to return the active Context on top of it.


Exception TypeCondition

The calling thread does not have an active Context.


Namespace: TechTalk.Genome

Assembly: TechTalk.Genome (in TechTalk.Genome.dll)


Editions: Professional, Evaluation, Express

See Also

Context Class | TechTalk.Genome Namespace | Push | CtxMgmtGuide.Chapter3