Пример #1
0
            internal static void RemoveAllEventHandlers(Action <EventRegistrationToken> removeMethod)
            {
                object instanceKey = WindowsRuntimeMarshal.NativeOrStaticEventRegistrationImpl.GetInstanceKey(removeMethod);
                List <EventRegistrationToken> registrationTokenList = new List <EventRegistrationToken>();

                WindowsRuntimeMarshal.NativeOrStaticEventRegistrationImpl.s_eventCacheRWLock.AcquireReaderLock(-1);
                try
                {
                    WindowsRuntimeMarshal.NativeOrStaticEventRegistrationImpl.TokenListCount tokenListCount;
                    ConditionalWeakTable <object, WindowsRuntimeMarshal.NativeOrStaticEventRegistrationImpl.EventRegistrationTokenListWithCount> tokenTableNoCreate = WindowsRuntimeMarshal.NativeOrStaticEventRegistrationImpl.GetEventRegistrationTokenTableNoCreate(instanceKey, removeMethod, out tokenListCount);
                    if (tokenTableNoCreate == null)
                    {
                        return;
                    }
                    lock (tokenTableNoCreate)
                    {
                        foreach (WindowsRuntimeMarshal.NativeOrStaticEventRegistrationImpl.EventRegistrationTokenListWithCount item_0 in (IEnumerable <WindowsRuntimeMarshal.NativeOrStaticEventRegistrationImpl.EventRegistrationTokenListWithCount>)tokenTableNoCreate.Values)
                        {
                            item_0.CopyTo(registrationTokenList);
                        }
                        tokenTableNoCreate.Clear();
                    }
                }
                finally
                {
                    WindowsRuntimeMarshal.NativeOrStaticEventRegistrationImpl.s_eventCacheRWLock.ReleaseReaderLock();
                }
                WindowsRuntimeMarshal.CallRemoveMethods(removeMethod, registrationTokenList);
            }
Пример #2
0
            internal static void RemoveAllEventHandlers(Action <EventRegistrationToken> removeMethod)
            {
                Dictionary <object, WindowsRuntimeMarshal.EventRegistrationTokenList> registrationTokenTable = WindowsRuntimeMarshal.ManagedEventRegistrationImpl.GetEventRegistrationTokenTable(removeMethod.Target, removeMethod);
                List <EventRegistrationToken> registrationTokenList = new List <EventRegistrationToken>();

                lock (registrationTokenTable)
                {
                    foreach (WindowsRuntimeMarshal.EventRegistrationTokenList item_0 in registrationTokenTable.Values)
                    {
                        item_0.CopyTo(registrationTokenList);
                    }
                    registrationTokenTable.Clear();
                }
                WindowsRuntimeMarshal.CallRemoveMethods(removeMethod, registrationTokenList);
            }