Well,
I think the code I provided is the best way to go. The reason for that is that there is gap (between 1 and 2 seconds) between the moment that you Start a stream and the moment when you actually receive data from twitter.
I believe that if you are willing to recover the tweets, it is for data consistency and you do not want to miss any tweet from the stream.
Therefore, waiting to the next tweet to be received will allow you to ensure that any tweet published within this gap will be restored and added to your database.
If you do not care about this case here are 2 solutions that will allow you to get the latest tweet published:
Linvi
I think the code I provided is the best way to go. The reason for that is that there is gap (between 1 and 2 seconds) between the moment that you Start a stream and the moment when you actually receive data from twitter.
I believe that if you are willing to recover the tweets, it is for data consistency and you do not want to miss any tweet from the stream.
Therefore, waiting to the next tweet to be received will allow you to ensure that any tweet published within this gap will be restored and added to your database.
If you do not care about this case here are 2 solutions that will allow you to get the latest tweet published:
// From any account if you do not already have a sample stream running on your machine + accountvar stream = Stream.CreateSampleStream(); stream.TweetReceived += (sender, args) => { var lastPublishedTweetId = args.Tweet.Id; stream.StopStream(); RestorePreviousDataBetween(sinceId, lastPublishedTweetId); }; // From another test account so that is does not "corrupt" the account profilevar tweet = Tweet.PublishTweet(Guid.NewGuid().ToString()); var lastPublishedTweetId = tweet.Id; tweet.Destroy(); RestorePreviousDataBetween(sinceId, lastPublishedTweetId);