/// <summary>
        /// Processes the next command in the command queue.
        /// This method is called in every block rendering cycle.
        /// </summary>
        public async Task ProcessNext()
        {
            MediaCommand command = null;

            lock (SyncLock)
            {
                if (Commands.Count == 0) return;
                command = Commands[0];
                Commands.RemoveAt(0);
            }

            await command.ExecuteAsync();
        }
Example #2
0
        /// <summary>
        /// Processes the next command in the command queue.
        /// This method is called in every block rendering cycle.
        /// </summary>
        public void ProcessNext()
        {
            DumpQueue($"Before {nameof(ProcessNext)}", false);
            if (MediaElement.IsTaskCancellationPending)
            {
                return;
            }

            MediaCommand command = null;

            lock (SyncLock)
            {
                if (Commands.Count == 0)
                {
                    return;
                }
                command = Commands[0];
                Commands.RemoveAt(0);
            }

            try
            {
                ExecutingCommand = command;
                command.ExecuteAsync().GetAwaiter().GetResult();
                DumpQueue($"After {nameof(ProcessNext)}", false);
            }
            catch (Exception ex)
            {
                MediaElement?.Logger.Log(MediaLogMessageType.Error, $"{ex.GetType()}: {ex.Message}");
                throw;
            }
            finally
            {
                ExecutingCommand = null;
            }
        }