문제

I've some code in my view model as follows:

miService.GetSomething(par1, par2)
.ObserveOnDispatcher()
.Subscribe(dt =>
 {
    DoSomething(dt);
 });

Then in my test, I'm "mocking" my service as follows:

miService.Setup(ms => ms.GetSomething(....))
.Returns(Observable.Return(XYZ));

The problem is that due to the ObserveOnDispatcher, the subscribe delegate is never executed.

I've seen some code with DispatcherFrame and PushFrame, but the problem is that I don't know "where", I can call

frame.Continue = false;
도움이 되었습니까?

해결책

You could try

var frame = new DispatcherFrame();
Dispatcher.CurrentDispatcher.BeginInvoke(
  DispatcherPriority.Background, 
  new Action(() => frame.Continue = false));
Dispatcher.PushFrame(frame);
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top