Esempio n. 1
0
        private void CheckEventSubscriptions()
        {
            var now = DateTime.Now;

            lock (_event_abos)
            {
                foreach (var pair in _event_abos.ToArray())
                {
                    var ev    = pair.Key;
                    var until = pair.Value.ExpireTime;
                    if (now > until)
                    {
                        // remove outdated abos
                        EventAbo abo = null;
                        if (_event_abos.ContainsKey(ev))
                        {
                            abo = _event_abos[ev];
                        }
                        _event_abos.Remove(ev);
                        if (abo != null)
                        {
                            abo.Event.OnUnregister();
                        }
                    }
                }
            }
        }
Esempio n. 2
0
        public void UnsubscribeEvent(EventInfo event_info)
        {
            if (event_info == null)
            {
                return;
            }
            EventAbo abo = null;

            lock (_event_abos)
            {
                if (_event_abos.ContainsKey(event_info.Name))
                {
                    abo = _event_abos[event_info.Name];
                }
                _event_abos.Remove(event_info.Name);
            }
            if (abo != null)
            {
                abo.Event.OnUnregister();
            }
        }