KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I have a winform application, and an observable set up 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 doesn't work, since the l => lb.Text = l.ToString() will not be run on the main thread which created the form, but I cannot figure out how to make it run on this thread. I assume, that I should use IObservable.SubscribeOn which takes either an IScheduler or a SynchronizationContext , but I don't know how to get the synchronizationcontext of the main thread, and the only Schedulers I could find were the static properties of Scheduler , such as Scheduler.CurrentThread , Immediate , NewThread , TaskPool and ThreadPool , none of which worked. My Rx version is 1.0.10621.
Tags (comma-separated)
Save Edits
Cancel