0

RX1.1.11111.1 から RX 2.0.20823.2 に移行しました。そして今、EventLoopScheduler からまれな例外が発生しました。

an Unhandled Exception occured in non UI thread.
System.NullReferenceException: Object reference not set to an instance of an object.
   at System.Reactive.Concurrency.EventLoopScheduler.Run()
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.ThreadHelper.ThreadStart()

誰が問題が何であるかを推測していますか?onError デリゲートを使用せず、メソッドの 1 つが失敗したためでしょうか?

コードの要点は次のとおりです。

EventLoopScheduler m_scheduler = new EventLoopScheduler();

. . .

m_receivedMessageHandler.StatusReceived.ObserveOn(m_scheduler) .Subscribe(p_unit => sendAll(m_retransmitManager, m_endPoint));

sendAll 内の例外がこの動作を引き起こす可能性はありますか?

4

1 に答える 1

0

サブスクライブに onError ハンドラーを配置する必要があります。そうしないと、アプリがクラッシュします。エラーを気にしない場合は、何もせずにそのまま食べてください。私は一度同じエラーがあったので、私はやった

            var subscription = observable.Subscribe(
                onNext: (v) => DoSomethingWith(v),
                onError: (Exception e) => {
                    // Just eat and log the exception.
                    Debug.WriteLine(e.ToString());
                }
            );

例外を気にしなかったとき。エラーが実際の問題である場合は、エラーを明示的に無視するか、どこかに記録することをお勧めします。

于 2012-11-08T12:32:53.767 に答える