public static void RemoveAllHandlersForObject(object obj) { if (obj == null) { throw new ArgumentNullException("obj", "No object given!"); } DOLEventHandlerCollection col = null; if (Lock.TryEnterReadLock(LOCK_TIMEOUT)) { try { m_gameObjectEventCollections.TryGetValue(obj, out col); } finally { Lock.ExitReadLock(); } } else { log.ErrorFormat("Timeout exceeded (Read) on attempt to RemoveAllHandlersForObject: {0}", obj.ToString()); } if (col != null) { col.RemoveAllHandlers(); if (Lock.TryEnterWriteLock(LOCK_TIMEOUT)) { try { m_gameObjectEventCollections.Remove(obj); } finally { Lock.ExitWriteLock(); } } else { log.ErrorFormat("Timeout exceeded (Write) on attempt to RemoveAllHandlersForObject: {0}", obj.ToString()); } } }
/// <summary> /// Removes all event handlers /// </summary> /// <param name="deep">Specifies if all local registered event handlers /// should also be removed</param> public static void RemoveAllHandlers(bool deep) { if (deep) { if (Lock.TryEnterWriteLock(LOCK_TIMEOUT)) { try { m_gameObjectEventCollections.Clear(); } finally { Lock.ExitWriteLock(); } } else { log.ErrorFormat("Timeout exceeded on attempt to RemoveAllHandlers."); } } m_globalHandlerCollection.RemoveAllHandlers(); }