System.Net.Sockets.OverlappedCache.Free C# (CSharp) Method

Free() private method

private Free ( ) : void
return void
        internal void Free()
        {
            InternalFree();
            GC.SuppressFinalize(this);
        }

Usage Example

Example #1
0
        internal void ExtractCache(ref OverlappedCache overlappedCache)
        {
            if (!m_UseOverlappedIO && !m_DisableOverlapped)
            {
                // Have to be super careful.  Socket isn't synchronized, so if a user calls End() twice, we don't want to
                // copy out this cache twice which could result in posting an IO with a deleted NativeOverlapped.
                OverlappedCache cache = m_Cache == null ? null : Interlocked.Exchange <OverlappedCache>(ref m_Cache, null);
                if (cache != null)
                {
                    // If overlappedCache is null, just slap it in there.  There's a chance for a conflict,
                    // resulting in a OverlappedCache getting finalized, but it's better than
                    // the interlocked.  This won't be an issue in most 'correct' cases.
                    if (overlappedCache == null)
                    {
                        overlappedCache = cache;
                    }
                    else
                    {
                        OverlappedCache oldCache = Interlocked.Exchange <OverlappedCache>(ref overlappedCache, cache);
                        if (oldCache != null)
                        {
                            oldCache.Free();
                        }
                    }
                }

                ReleaseUnmanagedStructures();
            }
        }
All Usage Examples Of System.Net.Sockets.OverlappedCache::Free