示例#1
0
 internal void Dispose(
     IntPtr pInterface,
     DetachCallbackEventHandlerDelegate pInvokeDetach)
 {
     if (this.Callbacks.IsValueCreated)
     {
         foreach (var tuple in this.Callbacks.Value.Values)
         {
             pInvokeDetach(pInterface, tuple.Item1);
             NativeMethods.Inspectable_Release(tuple.Item1);
         }
         this.Callbacks.Value.Clear();
     }
 }
示例#2
0
        internal void RemoveCallbackEventHandler(
            IntPtr pInterface,
            DetachCallbackEventHandlerDelegate pInvokeDetach,
            OnEventHandlerAdapter <T> callback)
        {
            Tuple <IntPtr, NativeMethods.OnCallbackEventHandler> tuple;

            if (!this.Callbacks.Value.TryGetValue(callback, out tuple))
            {
                throw new InvalidOperationException("Callback not registered");
            }
            PInvokeUtils.ThrowIfResult(pInvokeDetach(pInterface, tuple.Item1));
            NativeMethods.Inspectable_Release(tuple.Item1);
            this.Callbacks.Value.Remove(callback);
        }