예제 #1
0
 internal bool Donate(T entry)
 {
     // Assume anything could have been set to null, start no sync operation, this could be running during DomainUnload
     if (entry != null && ReentryGuardHelper.Enter(_id))
     {
         try
         {
             var entries  = _entries;
             var recycler = _recycler;
             if (entries != null && recycler != null)
             {
                 recycler.Invoke(entry);
                 entries.Add(entry);
                 return(true);
             }
             return(false);
         }
         catch (InvalidOperationException exception)
         {
             GC.KeepAlive(exception);
         }
         catch (NullReferenceException exception)
         {
             GC.KeepAlive(exception);
         }
         finally
         {
             ReentryGuardHelper.Leave(_id);
         }
     }
     return(false);
 }
예제 #2
0
 internal bool Donate(T entry)
 {
     if (!ReferenceEquals(entry, null) && ReentryGuardHelper.Enter(_id))
     {
         try
         {
             _recycler.Invoke(entry);
             _entries.Add(entry);
             return(true);
         }
         catch (NullReferenceException exception)
         {
             GC.KeepAlive(exception);
         }
         finally
         {
             ReentryGuardHelper.Leave(_id);
         }
     }
     return(false);
 }