In a C# console application, using System.Reactive.Linq, I'm trying to make an observable, where each item is the string result of some processing by another observable. I've created a simple repro using strings and characters. Warning, this example is completely CONTRIVED, and the point is that the nested .Wait() hangs.
class Program { static void Main(string[] args) { string[] fileNames = { "file1.doxc", "file2.xlsx", "file3.pptx" }; IObservable<string> files = fileNames.ToObservable(); string[] extensions = files.Select(fn => { var extension = fn.ToObservable() .TakeLast(4) .ToArray() .Wait(); // <<<<<<<<<<<<< HANG HERE return new string(extension); }) .ToArray() .Wait(); } } Again, this is not how I would find the suffix of many filenames. The question is how I can produce an Observable of strings, where the strings are computed from a completed observable.
If I pull out this code and run it alone, it completes fine.
var extension = fn.ToObservable() .TakeLast(4) .ToArray() .Wait(); There is something about the nested Wait() on the async methods, which I don't understand.
How can I code the nested async observables, so I can produce a simple array of string?
Thanks
-John
Wait()in the first place?