Exemple #1
0
        /// <summary>
        /// Adds a new request info row to the list
        /// </summary>
        /// <param name="header"></param>
        /// <returns>The index of the new entry</returns>
        public int AddRequestInfo(TVRequestInfo header)
        {
            int result = -1;

            try
            {
                lock (_lockData)                 //critical section begins
                {
                    if (header.Id == -1)
                    {
                        if (_firstIndex == -1)
                        {
                            _firstIndex = 0;
                            _lastIndex  = 0;
                        }
                        else
                        {
                            _lastIndex++;
                        }

                        //save the index in the request header
                        header.Id = _lastIndex;
                    }
                    else
                    {
                        if (_firstIndex == -1)
                        {
                            _firstIndex = header.Id;
                        }
                        _lastIndex = header.Id;
                    }
                    _requestInfos.Add(_lastIndex, header);
                    //new request header was added to the list
                    //this means that we have at least the request line
                    //call the RequestAdded event

                    result = _lastIndex;
                }                 //end critical section

                //now that the data was added invoke the event
                if (RequestEntryAdded != null)
                {
                    TVDataAccessorDataArgs e = new TVDataAccessorDataArgs(_lastIndex, header);
                    RequestEntryAdded.Invoke(e);
                }
            }
            catch (Exception ex)
            {
                SdkSettings.Instance.Logger.Log(TraceLevel.Error, "An error occured while adding a request info: {0}", ex.ToString());
            }

            return(result);
        }
Exemple #2
0
        /// <summary>
        /// Replaces the index at header.id with the passed object and signals that the request info was updated to all listeners
        /// </summary>
        /// <param name="header"></param>
        /// <returns>The index of the new entry</returns>
        public void UpdateRequestInfo(TVRequestInfo header)
        {
            lock (_lockData)
            {
                _requestInfos[header.Id] = header;
            }

            if (RequestEntryUpdated != null)
            {
                TVDataAccessorDataArgs e = new TVDataAccessorDataArgs(header.Id, header);
                RequestEntryUpdated.Invoke(e);
            }
        }