Subject <t>停止发布项目</t>

时间:2011-06-26 07:25:34

标签: c# mono system.reactive task-parallel-library

我有Subject<T>我正在通过OnNext发布项目,过了一段时间,在加载下,我得到了这个例外:

System.NullReferenceException: Object reference not set to an instance of an object
at System.Diagnostics.ExceptionExtensions.PrepareForRethrow (System.Exception exception) [0x00000] in <filename unknown>:0
at System.Concurrency.AsyncLock.Wait (System.Action action) [0x00000] in <filename unknown>:0
at System.Concurrency.Scheduler+<>c__DisplayClass4.<Schedule>b__0 () [0x00000] in <filename unknown>:0
at System.Concurrency.ImmediateScheduler.Schedule (System.Action action) [0x00000] in <filename unknown>:0
at System.Concurrency.Scheduler.Schedule (IScheduler scheduler, System.Action`1 action) [0x00000] in <filename unknown>:0
at System.ScheduledObserver`1[GetNotifyd.Superfeedr.FeedItem].EnsureActive () [0x00000] in <filename unknown>:0
at System.Collections.Generic.Subject`1[GetNotifyd.Superfeedr.FeedItem].OnNext (GetNotifyd.Superfeedr.FeedItem value) [0x00000] in <filename unknown>:0

发生这种情况后,我仍然可以通过OnNext发布项目,但我的订阅者不再收到任何内容。这是使用MS的.NET 3.5 Reactive Extensions DLL在mono 2.10.1下运行的(即我不认为它的单声道代码正在死亡)。我在Windows上尝试时没有看到这种情况,但我没有在那里运行相同的负载。作为OnNext参数的项绝对不是null,所以这不是原因。

知道可能导致此问题的原因或我如何恢复主题,或者我只需要创建一个新主题,通知我的所有订阅者订阅它?

由于它看起来像是一个Rx问题,我也在their forum

上报告了它

更新: issue was confirmed作为我正在使用的版本组合的Rx / mono问题。升级到最新的Rx(1.0.10605)解决了这个问题。

1 个答案:

答案 0 :(得分:3)

您可能在Rx中遇到竞争条件错误。

请注意this MSDN thread中的一张海报有类似的问题:来自堆栈跟踪的无法解释的NullReferenceException会触及AsyncLock.Wait。

现在,他的问题是由[ThreadStatic]无法在Windows Phone 7上运行引起的。[ThreadStatic]是否有可能在Mono上有微妙的行为?

我建议通过Rx论坛向Rx团队报告此错误。