Example #1
0
        /// <summary>
        /// Fires the specified animation event. This method performs
        /// null checking and thread synchronization on the
        /// SynchronizedObject when necessary.
        /// </summary>
        ///
        /// <param name="eventToFire">
        /// the animation event to fire.
        /// </param>
        protected void FireEvent(AnimationEventHandler eventToFire)
        {
            // Null check
            if (eventToFire == null)
            {
                return;
            }

            var args = new AnimationEventArgs(this);

            // If a SynchronizationObject is specified, fire the event
            // on the object's synchronized thread.
            if (this.SynchronizationObject != null)
            {
                this.SynchronizationObject.BeginInvoke(new Action(() =>
                {
                    eventToFire(this, args);
                }), null);
            }

            else
            {
                eventToFire(this, args);
            }
        }
Example #2
0
        /// <summary>
        /// Removes the specified animation from the list of running animations.
        /// </summary>
        ///
        /// <param name="animation">
        /// the animation to remove from the list of running animations. If this
        /// animation was not returned from one of the overloaded AddAnimation
        /// methods, it will not be in the list.
        /// </param>
        protected void RemoveAnimation(IAnimation animation, AnimationEventArgs args)
        {
            this.readerWriterLock.AcquireWriterLock(Timeout.Infinite);

            // Check if the animation is successfully removed.
            if (this.animations.Remove(animation))
            {
                // Remove the event handler for the animation.
                animation.AnimationEnded -= RemoveAnimation;
            }

            this.readerWriterLock.ReleaseWriterLock();
        }