Perhaps you could make your IObservable log and make your user interface subscribe to its changes?
Another option is to implement INotifyPropertyChanged and use PropertyChangedEventHandler to notify you of changes.
Here is a snippet of code showing you how to do this with NotifyPropertyChanged:
using System.ComponentModel; public class YourClass : INotifyPropertyChanged { public event PropertyChangedEventHandler PropertyChanged; private void NotifyPropertyChanged(String info) { if (PropertyChanged != null) { PropertyChanged(this, new PropertyChangedEventArgs(info)); } } protected void AddLogLine(String log) {
To register for changes, you simply do something like (in your user interface constructor):
YourClassInstance.PropertyChanged += new PropertyChangedEventHandler(MyFunctionToHandleLogChanges);
Note: make sure that you correctly removed and added the handler again if you changed your ClassInstance class
And then update your user interface in your interface class:
void MyFunctionToHandleLogChanges(object sender, PropertyChangedEventArgs e) { if (e.PropertyName == "Log") {
source share