How can I dispatch an PropertyChanged event from a subscription to an Interval based IObservable
- by James Hay
I'm getting an 'UnauthorizedAccesExpection - Invalid cross-thread access' exception when I try to raise a PropertyChanged event from within a subscription to an IObservable collection created through Observable.Interval().
With my limited threading knowledge I'm assuming that the interval is happening on some other thread while the event wants to happen on the UI thread??? An explanation of the problem would be very useful.
The code looks a little like:
var subscriber = Observable.Interval(TimeSpan.FromSeconds(1))
.Subscribe(x =>
{
Prop = x; // setting property raises a PropertyChanged event
});
Any solutions?