[NUI] Clean NUI codes from Adaptor.cs to Window.cs (#652)
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / internal / XamlBinding / SynchronizedList.cs
index 73918cb..a0761b4 100755 (executable)
@@ -42,7 +42,11 @@ namespace Tizen.NUI.Binding
 
         public int Count
         {
-            get { return _list.Count; }
+            get 
+            {
+                lock (_list)
+                    return _list.Count; 
+            }
         }
 
         bool ICollection<T>.IsReadOnly
@@ -71,14 +75,15 @@ namespace Tizen.NUI.Binding
 
         public IEnumerator<T> GetEnumerator()
         {
-            ReadOnlyCollection<T> snap = _snapshot;
-            if (snap == null)
+            lock (_list)
             {
-                lock (_list)
+                ReadOnlyCollection<T> snap = _snapshot;
+                if (snap == null)
+                {
                     _snapshot = snap = new ReadOnlyCollection<T>(_list.ToList());
+                }
+                return snap?.GetEnumerator();
             }
-
-            return snap?.GetEnumerator();
         }
 
         public int IndexOf(T item)
@@ -100,12 +105,14 @@ namespace Tizen.NUI.Binding
         {
             get
             {
-                ReadOnlyCollection<T> snap = _snapshot;
-                if (snap != null)
-                    return snap[index];
-
                 lock (_list)
+                {
+                    ReadOnlyCollection<T> snap = _snapshot;
+                    if (snap != null)
+                        return snap[index];
+
                     return _list[index];
+                }
             }
 
             set