I am trying to retrieve data from database using Entity-Framework 5.0 Code fast and Reactive Extensions (Rx). I am writing following code for that.
var obs = DataContext.GetDataContext().BreakdownCauses.OrderBy(x => x.Cause).ToObservable(Scheduler.NewThread);
obs.SubscribeOnDispatcher().Subscribe(x => ItemCollection.Add(slow(x)));
BreakdownCause slow(BreakdownCause cs)
{
System.Threading.Thread.Sleep(500);
return cs;
}
But it show me this warning :
'System.Reactive.Concurrency.Scheduler.NewThread' is obsolete: 'This property is no longer supported due to refactoring of the API surface and elimination of platform-specific dependencies. Please add a reference to the System.Reactive.PlatformServices assembly for your target platform and use NewThreadScheduler.Default to obtain an instance of this scheduler type. See http://go.microsoft.com/fwlink/?LinkID=260866 for more information.'
And at RunTime I get an Exception :
The calling thread cannot access this object because a different thread owns it.
Please suggests me how can i use Reactive Extensions (Rx) properly in EF5.0 Code fast in my WPF application or any batter way to call database asynchronously.