I have this:
watchers
.ToObservable() // needs to be observable
.SelectMany(watcher => // working on each watcher
Observable
// create a timer for the watcher
.Timer(watcher.StartTime, TimeSpan.FromHours(watcher.Interval))
.SelectMany(Observable.FromAsync(
async () => new { watcher, result = await CheckFolder(watcher.Path) })))
.Subscribe(x => Console.WriteLine(string.Format("Watcher: {0}\tResult: {1}\tTime: {2}", x.watcher.Name, x.result, DateTimeOffset.Now))); // tell everyone what happened.
Which is a nice little bit of code from this post that got me started down this road. The goal is to ping a web service (via the CheckFolder()
method) every time the Timer
s publish, based on a given start time and interval.
The trouble is, every time I run the program it outputs a single message for the first Watcher, and then the program exits without error. It gets the first answer, and it's finished.
How do get it to wait for the other publications from all the timers?
I'm almost positive I'm not asking this question the right way, but hopefully a little feedback will help me refine my question.
Thanks.