Example #1
0
        /// <summary>
        /// Gets the oldest client model (lowest ID) from the list.
        /// </summary>
        /// <returns></returns>
        public ClientModel GetOldestClientModelFromConnectedList()
        {
            // Create a list of the keys
            List <int> list = new List <int>(ConnectedClientModelList.Keys);

            // Check that there is at least on item in the list
            if (list.Count == 0)
            {
                return(null);
            }

            // Sort the list in ascending order
            list.Sort();

            // Retrieve the first (oldest) item in the list by smallest key value
            int oldestIndex = list[0];

            // Now retrieve the model from the dictionary
            ConnectedClientModelList.TryGetValue(oldestIndex, out var result);

            return(result);
        }