[Tizen.Applications.Common] Revert TizenSynchronizationContext.cs (#443)
authorpjh9216 <jh9216.park@samsung.com>
Mon, 3 Sep 2018 09:48:38 +0000 (18:48 +0900)
committerGitHub <noreply@github.com>
Mon, 3 Sep 2018 09:48:38 +0000 (18:48 +0900)
Signed-off-by: Junghoon Park <jh9216.park@samsung.com>
src/Tizen.Applications.Common/Tizen.Applications/TizenSynchronizationContext.cs

index 4dd40d0..741242c 100755 (executable)
@@ -16,7 +16,6 @@
 
 using System;
 using System.Collections.Concurrent;
-using System.Collections.Generic;
 using System.Threading;
 
 namespace Tizen.Applications
@@ -30,8 +29,7 @@ namespace Tizen.Applications
     {
         private readonly Interop.Glib.GSourceFunc _wrapperHandler;
         private readonly Object _transactionLock = new Object();
-        private readonly ConcurrentDictionary<int, KeyValuePair<Action,uint>> _handlerMap
-            = new ConcurrentDictionary<int, KeyValuePair<Action, uint>>();
+        private readonly ConcurrentDictionary<int, Action> _handlerMap = new ConcurrentDictionary<int, Action>();
         private int _transactionId = 0;
 
         /// <summary>
@@ -44,18 +42,6 @@ namespace Tizen.Applications
         }
 
         /// <summary>
-        /// Finalizer to clean up the native source
-        /// </summary>
-        ~TizenSynchronizationContext()
-        {
-            foreach (var s in _handlerMap.Values)
-            {
-                if (s.Value > 0)
-                    Interop.Glib.RemoveSource(s.Value);
-            }
-        }
-
-        /// <summary>
         /// Initilizes a new TizenSynchronizationContext and install into the current thread.
         /// </summary>
         /// <remarks>
@@ -128,8 +114,8 @@ namespace Tizen.Applications
             {
                 id = _transactionId++;
             }
-            _handlerMap.TryAdd(id, new KeyValuePair<Action,uint>(action,
-                Interop.Glib.IdleAdd(_wrapperHandler, (IntPtr)id)));
+            _handlerMap.TryAdd(id, action);
+            Interop.Glib.IdleAdd(_wrapperHandler, (IntPtr)id);
         }
 
         private bool Handler(IntPtr userData)
@@ -137,8 +123,9 @@ namespace Tizen.Applications
             int key = (int)userData;
             if (_handlerMap.ContainsKey(key))
             {
-                _handlerMap.TryRemove(key, out var p);
-                p.Key?.Invoke();
+                Action action;
+                _handlerMap.TryRemove(key, out action);
+                action?.Invoke();
             }
             return false;
         }