using System;
using System.Collections.Concurrent;
-using System.Collections.Generic;
using System.Threading;
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>
}
/// <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>
{
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)
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;
}