I have a winform application and the observed setup looks like this:
Form form = new Form(); Label lb = new Label(); form.Controls.Add(lb); Observable.Interval(TimeSpan.FromSeconds(1)) .Subscribe(l => lb.Text = l.ToString()); Application.Run(form);
This does not work, since l => lb.Text = l.ToString() will not start in the main thread that created the form, but I cannot figure out how to make it work in this thread. I suppose I should use IObservable.SubscribeOn , which accepts either IScheduler or SynchronizationContext , but I donβt know how to get the synchronous text of the main thread, and the only schedulers I could find were static Scheduler properties like Scheduler.CurrentThread , Immediate , NewThread , TaskPool and ThreadPool , none of which worked.
My version of Rx is 1.0.10621.
Boris Sep 14 2018-11-11T00: 00Z
source share