Example #1
0
        /// <summary>
        /// Method used to initialize the RequestEntryAdded event handler
        /// </summary>
        /// <param name="e"></param>
        private void RequestEntryAdded(TVDataAccessorDataArgs e)
        {
            if (_stopLoadingEvents)
            {
                return;
            }

            bool isFullQueue = false;

            lock (_listLock)
            {
                //queue request ids to be loaded to the list
                _requestHeaderEventsQueue.Enqueue(e.RequestId);

                if (_requestHeaderEventsQueue.Count >= _requestEventsQueueSize)
                {
                    isFullQueue = true;
                }
            }

            if (isFullQueue)                              //the events queue is full and tail is not on
            {
                this.BeginInvoke((MethodInvoker) delegate //use invoke to avoid cross-thread exceptions
                {
                    lock (_listLock)
                    {
                        //reset the full queue flag
                        isFullQueue = false;

                        //the queue is full load all the requests to the GUI
                        DrainRequestEvents();

                        //increase the queue size using an adaptive behavior, improves performance
                        if (!_tail)
                        {
                            //if tail is not on increase the size with the amount of rows from the selected row to the end of the list
                            if (_requestEventsQueueSize < _loadMaxAdvanceSize)
                            {
                                _requestEventsQueueSize =
                                    _dataGrid.Rows.Count - _dataGrid.Rows.GetFirstRow(DataGridViewElementStates.Selected);
                                if (_requestEventsQueueSize > _loadMaxAdvanceSize)
                                {
                                    _requestEventsQueueSize = _loadMaxAdvanceSize;
                                }
                            }
                            //also wait a little bit between two loads to prevent the gui from becoming unresponsive
                        }
                        else
                        {
                            _requestEventsQueueSize = _dataSource.RequestCount - _dataGrid.Rows.Count;
                        }
                    }
                });
            }
        }
Example #2
0
 /// <summary>
 /// Executes when the data source was cleared
 /// </summary>
 /// <param name="e"></param>
 private void DataCleared(TVDataAccessorDataArgs e)
 {
     this.Invoke((MethodInvoker) delegate
     {
         lock (_listLock)                 //prevent multiple threads from doing this at the same time
         {
             _dataGrid.Rows.Clear();
             _addedRows.Clear();
         }
     });
 }
 /// <summary>
 /// Finishes incomplete responses
 /// </summary>
 /// <param name="e"></param>
 private void DataSourceResponseAdded(TVDataAccessorDataArgs e)
 {
     lock (_workerLock)
     {
         if (e.RequestId != _currentId)
         {
             return;
         }
     }
     LoadRequest(e.RequestId);
 }
 /// <summary>
 /// A new request was selected
 /// </summary>
 /// <param name="e"></param>
 private void RequestSelected(TVDataAccessorDataArgs e)
 {
     if (!String.IsNullOrWhiteSpace(e.Header.Validation))
     {
         _requestViewer.SetHighlighting(Regex.Replace(e.Header.Validation, "\\$(body|header)=", ""), true);
     }
     else if (_currentSearchCriteria != null)
     {
         _requestViewer.SetHighlighting(_currentSearchCriteria.Texts[0], _currentSearchCriteria.IsRegex);
     }
     else
     {
         _requestViewer.SetHighlighting(String.Empty, false);
     }
     _requestViewerLoader.CallLoadRequest(e.RequestId);
 }
Example #5
0
 /// <summary>
 /// Requests when a request was unlinked from the list
 /// </summary>
 /// <param name="e"></param>
 private void RequestEntryRemoved(TVDataAccessorDataArgs e)
 {
     this.Invoke((MethodInvoker) delegate
     {
         lock (_listLock)                 //prevent multiple threads from doing this at the same time
         {
             int id          = e.RequestId;
             string stringId = id.ToString(NUMBER_FORMAT);
             if (_addedRows.ContainsKey(stringId))
             {
                 DataGridViewRow row = _addedRows[stringId];
                 _addedRows.Remove(stringId);
                 _dataGrid.Rows.Remove(row);
             }
         }
     });
 }
Example #6
0
        /// <summary>
        /// Mainly used to add response status for request headers that didn't have a response at the time
        /// </summary>
        /// <param name="e"></param>
        private void ResponseAdded(TVDataAccessorDataArgs e)
        {
            if (_stopLoadingEvents)
            {
                return;
            }

            this.Invoke((MethodInvoker) delegate
            {
                lock (_listLock)                 //prevent multiple threads from doing this at the same time
                {
                    int id          = e.RequestId;
                    string stringId = id.ToString(NUMBER_FORMAT);
                    if (_addedRows.ContainsKey(stringId))
                    {
                        DataGridViewRow row          = _addedRows[stringId];
                        row.Cells["_status"].Value   = e.Header.ResponseStatus;
                        row.Cells["_respTime"].Value = e.Header.ResponseTime.ToString(TIME_FORMAT);
                        decimal respSize             = (decimal)e.Header.ResponseLength / 1024;
                        row.Cells["_respSize"].Value = String.Format(SIZE_FORMAT, respSize);
                    }
                }
            });
        }
 private void DataCleared(TVDataAccessorDataArgs e)
 {
     ClearData();
 }