我想节流方向传感器Xamarin.Essential
如下:
Observable.FromEventPattern<OrientationSensorChangedEventArgs>(
ev => OrientationSensor.ReadingChanged += ev,
ev => OrientationSensor.ReadingChanged -= ev
)
.Throttle(TimeSpan.FromMilliseconds(500))
.Subscribe(x => { onOrientationChanged(x.Sender, x.EventArgs); });
OrientationSensor.Start(SensorSpeed.UI);
处理程序方法具有以下签名:
void onOrientationChanged(object sender, OrientationSensorChangedEventArgs e)
{
}
如果我省略该Throttle
方法,一切都会很好。在Throttle
那里,没有任何东西会着火。