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; } }
lock
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)