System.Runtime.Remoting.IdentityHolder.FlushIdentityTable C# (CSharp) Method

FlushIdentityTable() static private method

static private FlushIdentityTable ( ) : void
return void
        internal static void FlushIdentityTable()
        {
            // We need to guarantee that finally is not interrupted so that the lock is released.
            // TableLock has a long path without reliability contract.  To avoid adding contract on
            // the path, we will use ReaderWriterLock directly.
            ReaderWriterLock rwlock = TableLock;
            bool takeAndRelease = !rwlock.IsWriterLockHeld;

            RuntimeHelpers.PrepareConstrainedRegions();
            try{
                if (takeAndRelease)
                    rwlock.AcquireWriterLock(INFINITE);
                CleanupIdentities(null);
            }
            finally{
                if(takeAndRelease && rwlock.IsWriterLockHeld){
                    rwlock.ReleaseWriterLock();
                }
            }
        }