/// <summary> /// Adds an event handler to the list /// </summary> /// <param name="e">The event from which we add a handler</param> /// <param name="del">The callback method</param> public void AddHandler(RoadEvent e, RoadEventHandler del) { try { m_lock.AcquireWriterLock(TIMEOUT); try { WeakMulticastDelegate deleg = (WeakMulticastDelegate)m_events[e]; if (deleg == null) { m_events[e] = new WeakMulticastDelegate(del); } else { m_events[e] = WeakMulticastDelegate.Combine(deleg, del); } } finally { m_lock.ReleaseWriterLock(); } } catch (ApplicationException ex) { if (log.IsErrorEnabled) { log.Error("Failed to add event handler!", ex); } } }
public void AddHandler(RoadEvent e, RoadEventHandler del) { try { this.m_lock.AcquireWriterLock(3000); try { WeakMulticastDelegate deleg = (WeakMulticastDelegate)this.m_events[e]; if (deleg == null) { this.m_events[e] = new WeakMulticastDelegate(del); } else { this.m_events[e] = WeakMulticastDelegate.Combine(deleg, del); } } finally { this.m_lock.ReleaseWriterLock(); } } catch (ApplicationException ex) { LogProvider.Default.Error("Failed to add event handler!", ex); } }
public void AddHandler(RoadEvent e, RoadEventHandler del) { try { this.m_lock.AcquireWriterLock(3000); try { WeakMulticastDelegate weakMulticastDelegate = (WeakMulticastDelegate)this.m_events[e]; if (weakMulticastDelegate == null) { this.m_events[e] = new WeakMulticastDelegate(del); } else { this.m_events[e] = WeakMulticastDelegate.Combine(weakMulticastDelegate, del); } } finally { this.m_lock.ReleaseWriterLock(); } } catch (ApplicationException exception) { if (RoadEventHandlerCollection.log.IsErrorEnabled) { RoadEventHandlerCollection.log.Error("Failed to add event handler!", exception); } } }
/// <summary> /// Adds an event handler to the list. /// </summary> /// <param name="e">The event from which we add a handler</param> /// <param name="del">The callback method</param> public void AddHandler(DOLEvent e, DOLEventHandler del) { if (_lock.TryEnterWriteLock(LOCK_TIMEOUT)) { try { WeakMulticastDelegate deleg; if (!_events.TryGetValue(e, out deleg)) { _events.Add(e, new WeakMulticastDelegate(del)); } else { _events[e] = WeakMulticastDelegate.Combine(deleg, del); } } finally { _lock.ExitWriteLock(); } } }