diff --git a/Libraries/Opc.Ua.PubSub/IntervalRunner.cs b/Libraries/Opc.Ua.PubSub/IntervalRunner.cs index db26ccacb..a8a0d9b0b 100644 --- a/Libraries/Opc.Ua.PubSub/IntervalRunner.cs +++ b/Libraries/Opc.Ua.PubSub/IntervalRunner.cs @@ -184,18 +184,12 @@ private async Task ProcessAsync() nowTick = HiResClock.Ticks; if (nowTick < nextPublishTick) { - while (HiResClock.Ticks < nextPublishTick) - { - // Busy-wait and avoid overhead of Task.Delay for verry small wait times - } + SpinWait.SpinUntil(() => HiResClock.Ticks >= nextPublishTick); } } else if (sleepCycle >= 0 && sleepCycle <= 16) { - while (HiResClock.Ticks < nextPublishTick) - { - // Busy-wait and avoid overhead of Task.Delay for verry small wait times - } + SpinWait.SpinUntil(() => HiResClock.Ticks >= nextPublishTick); } lock (m_lock)