Ejemplo n.º 1
0
        protected override async Task Execute(CancellationToken token)
        {
            log.LogInformation("Starting twitter monitoring...");

            var keywords = string.IsNullOrEmpty(config.Keywords) ? new string[] { } : config.Keywords.Split(',');
            var follow   = string.IsNullOrEmpty(config.People) ? new string[] { } : config.People.Split(',');

            if (follow.Length == 0 &&
                keywords.Length == 0)
            {
                throw new NotSupportedException("Invalid selection");
            }

            var subscribtion = monitoring.MessagesReceiving
                               .ObserveOn(TaskPoolScheduler.Default)
                               .Subscribe(item => persistency.Save(item));
            await monitoring.Start(keywords, follow).ConfigureAwait(false);

            subscribtion.Dispose();
        }