/// <summary> /// Update statistics with a new tweet that has been received from the Twitter api /// </summary> /// <param name="jsonString"></param> public void ProcessTweet(string jsonString) { var tweet = JsonConvert.DeserializeObject <Tweet>(jsonString); // not sure why this is happening, but receiving empty tweets from the API occasionally - throw them away if (tweet == null) { return; } // this is compute intensive, perform outside of the lock var foundEmojis = _emojiHelper.FindEmojis(tweet.data.text); // update statistics with information about this tweet - lock to be threadsafe lock (padlock) { Averages.Recompute(); Emojis.AddProperties(foundEmojis); Hashtags.AddProperties(tweet.data.entities?.hashtags?.Select(x => x.tag)); Urls.AddProperties(tweet.data.entities?.urls); } }