LogSessionDeleted() private méthode

private LogSessionDeleted ( string key ) : void
key string
Résultat void
        /// <summary>
        /// Ends an external session export
        /// </summary>
        /// <param name="Key">Session key</param>
        /// <param name="RemoveSession">True to remove session from dictionary</param>
        public void EndExport(string Key, bool RemoveSession)
        {
            //This method resets the inuse property if the isExporting property is true

            if (Key == null)
            {
                throw new ArgumentNullException("Key");
            }

            AcquireReadLock();
            ISessionObject entry;

            try
            {
                dict.TryGetValue(Key, out entry);
            }
            finally
            {
                ReleaseReadLock();
            }

            if (entry == null)
            {
                //Session not found -- it's okay, don't freak out, session may have expired.
                return;
            }
            else
            {
                //Session Found
                if (entry.IsInUse)
                {
                    //The InUse flag, now check the isExporting flag
                    if (!entry.IsExporting)
                    {
                        Exception ex = new InvalidOperationException("EndExport must be called after a call to BeginExport");
                        Diags.LogApplicationError("EndExport must be called after a call to BeginExport -- Entry is InUse but IsExporting is false", ex);
                        throw ex;
                    }

                    try
                    {
                        //Delete session
                        if (RemoveSession)
                        {
                            AcquireWriteLock();
                            try
                            {
                                if (dict.Remove(Key))
                                {
                                    expiryList.Remove(Key);
                                    Diags.LogSessionDeleted(Key);
                                }
                            }
                            finally
                            {
                                ReleaseWriteLock();
                            }
                        }
                    }
                    finally
                    {
                        entry.IsExporting = false;
                        Diags.LogSessionExported(Key);
                        entry.CompareExchangeIsInUse(false, true);
                    }
                }
                else
                {
                    Exception ex = new InvalidOperationException("EndExport must be called after a call to BeginExport");
                    Diags.LogApplicationError("EndExport must be called after a call to BeginExport -- Entry is not in use", ex);
                    throw ex;
                }
            }
        }
        /// <summary>
        /// Removes a session from the dictionary
        /// </summary>
        /// <param name="Key">Session Key</param>
        /// <param name="LockCookie">Lock Cookie</param>
        /// <param name="IsExpiring">Indicates that the item is being removed because it's expiring</param>
        /// <param name="ExpiryDate">The Item expiry date (for comparison)</param>
        /// <param name="LockedSessionInfo">Locked session information if session is locked</param>
        /// <returns>Result of Action</returns>
        private SessionActionResult Remove(string Key, uint LockCookie, bool IsExpiring, DateTime ExpiryDate, out SessionResponseInfo LockedSessionInfo)
        {
            if (Key == null)
            {
                throw new ArgumentNullException("Key");
            }
            LockedSessionInfo = null;

            bool tryAgain;

            Diags.ResetDeadLockCounter();

            do
            {
                tryAgain = false;
                AcquireReadLock();
                ISessionObject entry;
                try
                {
                    dict.TryGetValue(Key, out entry);
                }
                finally
                {
                    ReleaseReadLock();
                }

                if (entry == null)
                {
                    //Session not found
                    Diags.LogSessionNotFound(Key);
                    return(SessionActionResult.NotFound);
                }
                else
                {
                    //Session Found
                    if (entry.CompareExchangeIsInUse(true, false) == false)
                    {
                        try
                        {
                            //The InUse flag is set and so this code section has exclusive access to this session object
                            AcquireWriteLock();

                            try
                            {
                                //Check again to be sure, now that the write-lock has been obtained
                                ISessionObject oldEntry = entry;
                                if (!dict.TryGetValue(Key, out entry))
                                {
                                    //ooops -- another thread deleted the session from the dictionary while this thread
                                    //was either trying to do the compareExchange (or if buggy, while obtaining the write-lock)
                                    //so try again
                                    oldEntry.CompareExchangeIsInUse(false, true); //unlock the previously locked item
                                    tryAgain = true;
                                    continue;
                                }

                                if (IsExpiring)
                                {
                                    DateTime timeStamp;
                                    if (expiryList.TryGetTimeStamp(Key, out timeStamp))
                                    {
                                        if (timeStamp != ExpiryDate)
                                        {
                                            //The expiration date on this session was updated, so leave
                                            return(SessionActionResult.OK);
                                        }
                                    }
                                }

                                if (!IsExpiring && entry.IsLocked) //Locked items DO expire. if not expiring, LockCookie has to match session's
                                {
                                    if (!entry.UnLock(LockCookie))
                                    {
                                        //Lockcookie did not match
                                        LockedSessionInfo = (SessionResponseInfo)entry.CreateResponseInfo();
                                        Diags.LogSessionIsLocked(Key);
                                        return(SessionActionResult.Locked);
                                    }
                                }

                                if (dict.Remove(Key))
                                {
                                    expiryList.Remove(Key);
                                    if (IsExpiring)
                                    {
                                        Diags.LogSessionExpired(Key);
                                    }
                                    else
                                    {
                                        Diags.LogSessionDeleted(Key);
                                    }
                                }
                                else
                                {
                                    //This should never happen
                                    Diags.Fail("ASSERTION Failed -- Session dictionary was unable to remove key\r\n");
                                }
                            }
                            finally
                            {
                                ReleaseWriteLock();
                            }
                        }
                        finally
                        {
                            if (entry != null)
                            {
                                entry.CompareExchangeIsInUse(false, true);
                            }
                        }
                    }
                    else
                    {
                        //Is this entry being exported?
                        if (entry.IsExporting)
                        {
                            //This session is already been exported so leave
                            Diags.ResetDeadLockCounter();
                            return(SessionActionResult.Exporting);
                        }

                        //Another thread is using this session and will be done soon so try again

                        Thread.Sleep(1); //pause for 1 ms
                        tryAgain = true;
                    }

                    Diags.DetectDeadLock(Key, DeadLockIterationCount); //Signal a deadlock after 2000 iterations
                }
            } while (tryAgain);

            Diags.ResetDeadLockCounter(); //Signal deadlock was freed
            return(SessionActionResult.OK);
        }