Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ObservableAsPropertyHelper raising PropertyChanged on thread other than the UI thread in Silverlight #6

Closed
Aesir opened this issue Oct 26, 2010 · 2 comments
Labels

Comments

@Aesir
Copy link

Aesir commented Oct 26, 2010

In the "Implementing search with ObservableAsPropertyHelper" blog post it's stated

One of the cool things about ObservableAsPropertyHelper, is that it guarantees that it will run notifications on the UI thread via the Dispatcher so that you don’t have to think about what thread the observable notification came in on.

When I use the following code

_CurrentCustomer = new ObservableAsPropertyHelper(currentNameObservable, _ => this.RaisePropertyChanged("CurrentCustomer"));

I get a System.UnauthorizedAccessException("Invalid cross-thread access.") in ReactiveObject.RaisePropertyChanged(string propertyName) every time currentNameObservable raises a new value.

The problem seems to be that the default IScheduler for ObservableAsPropertyHelper is not the Dispatcher. At the end of the RxApp static constructor you have

if (InUnitTestRunner())
{
//...
}
else
{
DeferredScheduler = Scheduler.Dispatcher;
}

if SILVERLIGHT

DeferredScheduler = Scheduler.ThreadPool;

else

TaskpoolScheduler = Scheduler.TaskPool;

endif

which resets the DeferredScheduler for Silverlight to Scheduler.ThreadPool. I'm guessing that assignment for #if SILVERLIGHT should have been

TaskpoolScheduler = Scheduler.ThreadPool;
@anaisbetts
Copy link
Member

Yes, I just noticed that this morning

@anaisbetts
Copy link
Member

Fixed as of today

@lock lock bot added the outdated label Jun 26, 2019
@lock lock bot locked and limited conversation to collaborators Jun 26, 2019
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants