0
我想讓我的頭圍繞Observable模式,並基本解決現有代碼中的問題,該問題不會在事件觸發時通知。反應性Linq Observable不會通知事件何時被觸發
,我觀察到的事件被定義爲ResizeGroupItemEnded
:
public event EventHandler<StGroupItemsModified> ResizeGroupItemEnded
因此,該模式的設置如下:
private readonly IDisposable _groupUpdates;
private static readonly TimeSpan UpdateThrottle = TimeSpan.FromMilliseconds(300);
...
_groupUpdates = Observable.FromEventPattern<EventHandler<StGroupItemsModified>, PropertyChangedEventArgs>(e => groupUICtrl.ResizeGroupItemEnded += e, e => groupUICtrl.ResizeGroupItemEnded -= e)
.Throttle(UpdateThrottle)
.ObserveOn(SynchronizationContext.Current)
.Subscribe(x => RefreshVLines());
...
public void Dispose()
{
...
}
private void RefreshVLines()
{
// We should be notified here when groupUICtrl.ResizeGroupItemEnded triggers
}
爲什麼RefreshVLinesStep()
不叫當groupUICtrl.ResizeGroupItemEnded
被觸發?請有任何想法嗎?
簡化它,這可能只是一個錯字 - 但是你正在訂閱'RefreshVLines()'而不是'RefreshVLinesStep()'。你能確認這是否是一個錯字? – Enigmativity
是的,這是一個錯字。感謝您觀察 – Nostradamus
您所展示的代碼中沒有任何內容解釋發生了什麼。你需要提供[mcve]。 – Enigmativity