コード例 #1
0
            /// <include file="doc\NativeMethods.uex" path="docs/doc[@for="NativeMethods.HandleCollector.HandleType.Remove"]/*">
            /// <devdoc>
            ///     Removes the given handle from our monitor list.
            /// </devdoc>
            internal IntPtr Remove(IntPtr handle)
            {
                if (handle == IntPtr.Zero)
                {
                    return(handle);
                }
                int currentCount = 0;

                lock (this)
                {
                    handleCount--;
#if DEBUG_HANDLECOLLECTOR
                    Debug.Assert(handles.Contains(handle));
                    handles.Remove(handle);
#endif
                    if (handleCount < 0)
                    {
                        System.Diagnostics.Debug.Fail("Handle collector underflow for type '" + name + "'");
                        handleCount = 0;
                    }
                    currentCount = handleCount;
                }
                lock (internalSyncObject)
                {
                    if (HandleCollector.HandleRemoved != null)
                    {
                        HandleCollector.HandleRemoved(name, handle, currentCount);
                    }
                }
                return(handle);
            }
コード例 #2
0
 internal IntPtr Remove(IntPtr handle)
 {
     if (handle != IntPtr.Zero)
     {
         int currentHandleCount = 0;
         lock (this)
         {
             this.handleCount--;
             if (this.handleCount < 0)
             {
                 this.handleCount = 0;
             }
             currentHandleCount = this.handleCount;
         }
         lock (HandleCollector.internalSyncObject)
         {
             if (HandleCollector.HandleRemoved != null)
             {
                 HandleCollector.HandleRemoved(this.name, handle, currentHandleCount);
             }
         }
     }
     return(handle);
 }