Well, someone can change the static field and they will see the last value set depending on the scheduling of threads and processors. However, for a safe implementation, you must define another static object and use it to lock and grant your access to the variable through the static property.
private static object lockObject = new object();
private static int _MyValue = 0;
public static int MyStaticValue{
get{
int v = 0;
lock(lockObject){
v = _MyValue;
}
return v;
}
set{
lock(lockObject){
_MyValue = value;
}
}
}
-, , Service Host WCF .
IIS , , .
- / . HttpContext.Current.Server( ASP.NET).