private async Task Tweet(TimeSpan timeInLitterBox) { if (IsTweetingTooFrequently()) { return; } if (DurationIsTooShort(timeInLitterBox)) { return; } UpdateCounter(); var message = GenerateMessage(); _log.Verbose("Trying to tweet '" + message + "'."); try { await _twitterClientService.Tweet(message); _lastTweetTimestamp = DateTime.Now; _log.Info("Successfully tweeted: " + message); } catch (Exception exception) { _log.Warning("Failed to tweet. " + exception.Message); } }
public void Execute() { Task.Run(async() => await _twitterService.Tweet(_messageProvider())); }