示例#1
0
        private void OnTwitterListenerElapsed(object sender, ElapsedEventArgs e)
        {
            // Stop the timer while we are processing as MS will otherwise fire another elapsed event on a different thread pool thread.
            _twitterListener.Stop();

            try
            {
                var mcAfeeLastTweet = User.GetUserFromScreenName(McAfeeTwitterName).Status;

                if (_altCoinFinder.TryFindCoinOfTheDay(mcAfeeLastTweet.Text, _currenciesCache.Values, out var coinOfTheDay))
                {
                    Console.WriteLine("Coin of the day [{0}] found!", coinOfTheDay);
                    Console.WriteLine("Placing BUY order...");

                    var shortName = _currenciesCache
                                    .FirstOrDefault(x => x.Value.Equals(coinOfTheDay, StringComparison.OrdinalIgnoreCase)).Key;

                    _dataProvider.PlaceBuyOrder(shortName);
                }
                else
                {
                    // Coin not found, keep on polling Twitter.
                    _twitterListener.Start();
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine($"Excetpion {ex.Message}");
            }
        }