From 1225c746c07d95001e96ba0c6e7841509dc374be Mon Sep 17 00:00:00 2001 From: inga-lovinde <52715130+inga-lovinde@users.noreply.github.com> Date: Sat, 10 Jul 2010 13:14:17 +0000 Subject: [PATCH] Locking fixes in SqlObject --- Common/SqlObject.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Common/SqlObject.cs b/Common/SqlObject.cs index cbf2746..6db7fde 100644 --- a/Common/SqlObject.cs +++ b/Common/SqlObject.cs @@ -69,6 +69,14 @@ namespace FLocal.Common { } } + protected void LoadFromHashIfNotLoaded(Dictionary data) { + lock(this.lockInitializer) { + if(this.isLoaded) return; + this.fromHash(data); + this.isLoaded = true; + } + } + protected void LoadIfNotLoaded() { if(!this.isLoaded) { lock(this.lockInitializer) { @@ -120,7 +128,7 @@ namespace FLocal.Common { int id = int.Parse(row[table.idName]); loadedIds.Add(id); if(!rawRes.ContainsKey(id)) throw new CriticalException("wrong id"); - rawRes[id].LoadFromHash(row); + rawRes[id].LoadFromHashIfNotLoaded(row); } }