Example #1
0
        /// <summary>
        /// The method responsible for the filter operation
        /// </summary>
        private void FilterThreadMethod()
        {
            //block anew new threads from starting
            _filterWorkerEvent.Reset();

            //reset the stopRequested flag
            _stopRequested = false;


            FilterTaskQueue taskQueue = new FilterTaskQueue();

            //clear all the rows and re-add them, unfortunately due to performance issues
            //in DataGridView we can't just hide rows
            _list.Invoke((MethodInvoker) delegate
            {
                _list.ClearAllRows();
            });

            TVRequestInfo header;

            int currIndex = -1;

            //calculate visibility and re-add to the list
            while ((header = _list.DataSource.GetNext(ref currIndex)) != null)
            {
                if (_stopRequested)
                {
                    break;
                }

                taskQueue.Enqueue(header);

                if (taskQueue.Count >= FILTER_EVENTS_QUEUE_SIZE)
                {
                    Display(taskQueue);
                }
            }

            //drain remaining requests
            if (taskQueue.Count > 0 && !_stopRequested)
            {
                Display(taskQueue);
            }

            //allow new threads to start
            _filterWorkerEvent.Set();
        }
Example #2
0
        /// <summary>
        /// Starts a display operation
        /// </summary>
        /// <param name="taskQueue">Queue with request headers that should be added to the list</param>
        private void Display(FilterTaskQueue taskQueue)
        {
            TVRequestInfo currentTask;

            _list.Invoke((MethodInvoker) delegate
            {
                _list.SuspendLayout();
                while (taskQueue.Count > 0 && !_stopRequested)
                {
                    currentTask = taskQueue.Dequeue();
                    _list.AddRow(currentTask, false);
                }
                _list.ResumeLayout();
                if (!_stopRequested)
                {
                    Thread.Sleep(DISPLAY_DELAY);                     //sleep a bit to allow user interaction with the list
                }
            });
        }