Exemplo n.º 1
0
 protected override void OnAddReference()
 {
     if (ComponentTracker.Enable && ComponentTracker.EnableEvents)
     {
         ComponentTracker.NotifyEvent(this, ComponentEventType.AddReference);
     }
 }
Exemplo n.º 2
0
        /// <inheritdoc/>
        int IReferencable.AddReference()
        {
            if (ComponentTracker.Enable && ComponentTracker.EnableEvents)
            {
                ComponentTracker.NotifyEvent(this, ComponentEventType.AddReference);
            }

            int newCounter = Interlocked.Increment(ref counter);

            if (newCounter <= 1)
            {
                throw new InvalidOperationException(FrameworkResources.AddReferenceError);
            }
            return(newCounter);
        }
Exemplo n.º 3
0
        /// <inheritdoc/>
        int IReferencable.Release()
        {
            if (ComponentTracker.Enable && ComponentTracker.EnableEvents)
            {
                ComponentTracker.NotifyEvent(this, ComponentEventType.Release);
            }

            int newCounter = Interlocked.Decrement(ref counter);

            if (newCounter == 0)
            {
                Destroy();
            }
            else if (newCounter < 0)
            {
                throw new InvalidOperationException(FrameworkResources.ReleaseReferenceError);
            }
            return(newCounter);
        }