Entity-Framework 5.0 Code fast および Reactive Extensions (Rx) を使用して、データベースからデータを取得しようとしています。そのために次のコードを書いています。
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;
}
しかし、それは私にこの警告を表示します:
'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.'
そして実行時に私は例外を取得します:
The calling thread cannot access this object because a different thread owns it.
WPFアプリケーションでEF5.0コードでReactive Extensions(Rx)を適切に使用する方法、またはデータベースを非同期で呼び出すバッター方法を提案してください。