using System; using System.Runtime.InteropServices; internal class TimePassed(int timePeriod) { private int TIME_UNTIL_OK = timePeriod; private DateTime m_lastTime = DateTime.Now; [return: MarshalAs(UnmanagedType.U1)] public bool TimeHasPassed() { bool result = false; if (DateTime.Now.Subtract(m_lastTime).Seconds >= TIME_UNTIL_OK) { DateTime now = DateTime.Now; m_lastTime = now; result = true; } return result; } }