Example #1
0
 public void AddRef()
 {
     lock (this.syncObject)
     {
         SafeRefCountedContainer <TItem> safeRefCountedContainer = this;
         safeRefCountedContainer.refCount = safeRefCountedContainer.refCount + 1;
     }
 }
Example #2
0
 private void Release(bool disposeManagedResources)
 {
     lock (this.syncObject)
     {
         if (this.refCount > 0)
         {
             SafeRefCountedContainer <TItem> safeRefCountedContainer = this;
             safeRefCountedContainer.refCount = safeRefCountedContainer.refCount - 1;
             if (this.refCount == 0)
             {
                 IDisposable disposable = (object)this.instance as IDisposable;
                 if (disposable != null)
                 {
                     disposable.Dispose();
                 }
                 GC.SuppressFinalize(this);
             }
         }
     }
 }