コード例 #1
0
        /// <summary>
        /// Flushs the update queue. Takes the list of all updates queued for the client and calls the client's callback, passing this list as parameter
        /// </summary>
        private void FlushUpdateQueue()
        {
            while (true)
            {
                bool gotLock = false;
                try
                {
                    QueueLock.Enter(ref gotLock);

                    if (UpdateQueue.Count > 0)
                    {
                        InvokeClientCallbacks();
                        UpdateQueue.Clear();
                    }
                }
                finally
                {
                    if (gotLock)
                    {
                        QueueLock.Exit();
                    }
                }

                // Wait for updates to accumulate (to send them in batches)
                Thread.Sleep(10);
            }
        }
コード例 #2
0
        /// <summary>
        /// Adds update information about an entity to the update queue after having received an attributeChanged event
        /// </summary>
        /// <param name="sender">Entity that invoked the attribute change event</param>
        /// <param name="e">Event Arguments</param>
        private void AddEntityUpdateToQueue(Object sender, ChangedAttributeEventArgs e)
        {
            bool gotLock = false;

            try
            {
                QueueLock.Enter(ref gotLock);
                UpdateQueue.Add(CreateUpdateInfoFromEventArgs((Entity)sender, e));
            }
            finally
            {
                if (gotLock)
                {
                    QueueLock.Exit();
                }
            }
        }
コード例 #3
0
        /// <summary>
        /// Removes all unsent update information of a removed entity from the update queue
        /// </summary>
        /// <param name="entityGuid">Guid of the removed entity/param>
        private void RemoveEntityFromQueue(Entity entity)
        {
            bool gotLock = false;

            try
            {
                QueueLock.Enter(ref gotLock);

                foreach (UpdateInfo entityUpdate in UpdateQueue)
                {
                    if (entityUpdate.entityGuid.Equals(entity.Guid))
                    {
                        UpdateQueue.Remove(entityUpdate);
                    }
                }
            }
            finally
            {
                if (gotLock)
                {
                    QueueLock.Exit();
                }
            }
        }