public void EndInit() { var initDone = false; lock (this.lockObj) { this.initCount--; if (this.initCount == 0) { this.IsInitializing = false; this.IsInitialized = true; initDone = true; } #if DEBUG if (this.initCount < 0) { DiagnosticsHelper.WriteLine(string.Format("WARNING: initCount falls below 0 for {0}", this.GetType().Name)); } #endif } if (initDone) { this.OnInitialized(); } }