예제 #1
0
        /// <summary>
        /// Pauses the specified wrokers.
        /// </summary>
        /// <param name="wait">if set to <c>true</c> waits for the operation to complete.</param>
        /// <param name="read">if set to <c>true</c> executes the opration on the reading worker.</param>
        /// <param name="decode">if set to <c>true</c> executes the opration on the decoding worker.</param>
        /// <param name="render">if set to <c>true</c> executes the opration on the rendering worker.</param>
        public void Pause(bool wait, bool read, bool decode, bool render)
        {
            if (IsDisposed)
            {
                return;
            }

            var tasks = new Task[(read ? 1 : 0) + (decode ? 1 : 0) + (render ? 1 : 0)];
            var index = 0;

            if (read)
            {
                tasks[index] = Reading.PauseAsync();
                index++;
            }

            if (decode)
            {
                tasks[index] = Decoding.PauseAsync();
                index++;
            }

            if (render)
            {
                tasks[index] = Rendering.PauseAsync();
            }

            if (wait)
            {
                Task.WaitAll(tasks);
            }
        }