Ejemplo n.º 1
0
Archivo: timer2.cs Proyecto: qmgindi/Au
        /// <summary>
        /// Creates and starts new periodic timer.
        /// </summary>
        /// <param name="milliseconds">Time interval (period) of calling the callback function. Valid values are 0 - uint.MaxValue-2.</param>
        /// <param name="timerAction">Callback function.</param>
        /// <param name="tag">Something to pass to the callback function as <see cref="Tag"/>.</param>
        /// <param name="firstAfter">null (default) or time interval after which to call the callback function first time. Valid values are 0 - uint.MaxValue-2.</param>
        /// <exception cref="ArgumentOutOfRangeException"></exception>
        /// <remarks>
        /// Calls <see cref="Timer.Change(long, long)"/>.
        /// </remarks>
        public static timer2 every(long milliseconds, Action <timer2> timerAction, object tag = null, long?firstAfter = null)
        {
            var t = new timer2(timerAction)
            {
                Tag = tag
            };

            t.Every(milliseconds, firstAfter);
            return(t);
        }
Ejemplo n.º 2
0
Archivo: timer2.cs Proyecto: qmgindi/Au
        /// <summary>
        /// Creates and starts new one-time timer.
        /// </summary>
        /// <param name="milliseconds">Time interval after which to call the callback function. Valid values are 0 - uint.MaxValue-2. If -1, stops without disposing.</param>
        /// <param name="timerAction">Callback function.</param>
        /// <param name="tag">Something to pass to the callback function as <see cref="Tag"/>.</param>
        /// <exception cref="ArgumentOutOfRangeException"></exception>
        /// <remarks>
        /// Calls <see cref="Timer.Change(long, long)"/>.
        /// </remarks>
        public static timer2 after(long milliseconds, Action <timer2> timerAction, object tag = null)
        {
            var t = new timer2(timerAction)
            {
                Tag = tag
            };

            t.After(milliseconds);
            return(t);
        }