public bool RestartTimer(bool updateValue = false) { if (ValueChangedTimer == null) { return(false); } if (updateValue) { LastValue = Read(LastValue.Length, ValueChangedOffset); } ValueChangedTimer.Change(Frequency, Timeout.Infinite); bool ret = ValueChangedSuspended; ValueChangedSuspended = false; return(ret); }
public bool SuspendTimer() { ValueChangedMutex.WaitOne(); try { if (ValueChangedSuspended) { return(false); } ValueChangedTimer.Change(Timeout.Infinite, Timeout.Infinite); ValueChangedSuspended = true; return(true); } finally { ValueChangedMutex.ReleaseMutex(); } }