我已经调查这个Rx问题好几天了,一直画空白,所以希望这可能会对某人响起。当没有节流时,相同的订阅可以正常工作,但是一旦添加了节流(如下所示),就会抛出异常。完全复制。知道"忽略"是什么吗?为什么找不到它?
_locationManager.LocationChanged.Throttle (TimeSpan.FromSeconds (10)).Subscribe (LocationHandle);
{System.MissingFieldException: Field 'System.Reactive.Stubs`1[System.Object].Ignore' not found.
at System.Reactive.Disposables.CompositeDisposable.Dispose () [0x00000] in <filename unknown>:0
at System.Reactive.Disposables.SingleAssignmentDisposable.Dispose () [0x00000] in <filename unknown>:0
at System.Reactive.Disposables.SerialDisposable.set_Disposable (IDisposable value) [0x00000] in <filename unknown>:0
at System.Reactive.Linq.Observαble.Throttle`1+_[Android.Locations.Location].OnNext (Android.Locations.Location value) [0x00000] in <filename unknown>:0
at System.Reactive.Subjects.Subject`1[Android.Locations.Location].OnNext (Android.Locations.Location value) [0x00000] in <filename unknown>:0
at rdf.LocationManager.RegisterNewLocation (Android.Locations.Location location) [0x00009] in /Users/xxx/rdf/Rdf/Location/RdfLocationManager.cs:61 }
Static members:
Non-public members:
Data: Count=0
HResult: -2146233071
HelpLink: (null)
InnerException: (null)
Message (System.Exception): "Cannot access a class member."
Message (System.MissingMemberException): "Member System.Reactive.Stubs`1[System.Object].Ignore not found."
Message (System.MissingFieldException): "Field 'System.Reactive.Stubs`1[System.Object].Ignore' not found."
Source: "System.Reactive.Core"
StackTrace: " at System.Reactive.Disposables.CompositeDisposable.Dispose () [0x00000] in <filename unknown>:0 n at System.Reactive.Disposables.SingleAssignmentDisposable.Dispose () [0x00000] in <filename unknown>:0 n at System.Reactive.Disposables.SerialDisposable.set_Disposable (IDisposable value) [0x00000] in <filename unknown>:0 n at System.Reactive.Linq.Observαble.Throttle`1+_[Android.Locations.Location].OnNext (Android.Locations.Location value) [0x00000] in <filename unknown>:0 n at System.Reactive.Subjects.Subject`1[Android.Locations.Location].OnNext (Android.Locations.Location value) [0x00000] in <filename unknown>:0
原来Observable.Throttle()不是我正在寻找的方法。Throttle()忽略后续消息,直到经过的时间过期。这与Observable.Sample()有微妙的不同,后者正是我所寻找的,将快速序列采样为较慢的序列。以我的方式使用Throttle()的效果是我的序列从未开始。