You probably want a static value with an instance property.
private static int _value;
public int Value
{
get { return _value; }
set { _value = value; }
}
Just remember that if your client code is multi-threaded you'll need to wrap this with locking code, because a static field spans threads.
And remember that if you do this on the server, this static field will not only span threads, but it will span users. It isn't scoped at the user level, it is scoped at the AppDomain level - which essentially means the virtual root.
If you need this to work on the server in a per-user manner, you might consider using Csla.ApplicationContext.LocalContext, which is scoped per-user (and per-client request). On the client, LocalContext is per-thread, so you avoid threading issues in one way, but you must remember that a value set on one thread won't be available to other threads.
(except in Silverlight, where LocalContext is at the AppDomain level because there is no concept of per-thread storage)
Copyright (c) Marimer LLC