I have a following class at server-side.
public class Sample { private enum Status { NotEvaluated, Yes, No } private static object _lockObj = new object(); private static Status _status = Status.NotEvaluated; public static Status GetStatus() { if (_status == Status.NotEvaluated) { lock (_lockObj) { if (_status == Status.NotEvaluated) { //some evaluation code which sets status to either Yes/No; _status = Status.Yes; } } } return _status; } } Is anything wrong in locking mechanism above? do i need to lock at all? Because it is server-side (multiple requests will be there) and the variable is static i would think it should be locked at the time of evaluation.
correct me if i am wrong.
Thanks