我有一个方法叫做Subscribe()
在哪里做这个:-
private void Subscribe(){
IObservable<long> timer = Observable.Interval(TimeSpan.FromMilliseconds(250), Scheduler.NewThread);
IConnectableObservable<long> TimerPublisher = timer.Publish();
TimerPublisher.Connect();
this.DisposeMonsterAction = TimerPublisher.Subscribe(tick => MonsterAction());
var timer = from tick in world.TimerPublisher where tick % 1 == 0 select tick;
this.DisposeMonstersDeath = timer .Subscribe(tick => MonstersDeath());
}
所以MonsterAction()
每 250 毫秒被调用一次,然后MonsterDeath
每 1 秒被调用一次,但它不是那样工作的,MonsterDeath
每 250 毫秒被调用一次,那么我该如何解决这个问题?