コード例 #1
0
        /// <summary>
        /// Invokes repeatedly the specified callback function on the specified interval and/or delay.
        /// </summary>
        /// <param name="interval">Specifies the interval of the repetition.</param>
        /// <param name="count">Specifies the maximum amount of calls. (0 = unlimited)</param>
        /// <param name="callback">Specifies the callback to invoke.</param>
        /// <param name="state">Specifies a state object which will be passed to the callback function.</param>
        /// <returns>Returns the timer object used for this operation.</returns>
        public static Timer PeriodicCall <T>(TimeSpan interval, int count, TimerStateCallback <T> callback, T state)
        {
            Timer t = new StateCallTimer <T>(TimeSpan.Zero, interval, 0, callback, state);

            t.Priority = GetPriority(interval);
            t.Start();
            return(t);
        }
コード例 #2
0
        /// <summary>
        /// Invokes repeatedly the specified callback function on the specified interval and/or delay.
        /// </summary>
        /// <param name="delay">Specifies the amount of time to wait before invoking the first callback.</param>
        /// <param name="interval">Specifies the interval of the repetition.</param>
        /// <param name="count">Specifies the maximum amount of calls. (0 = unlimited)</param>
        /// <param name="callback">Specifies the callback to invoke.</param>
        /// <param name="state">Specifies a state object which will be passed to the callback function.</param>
        /// <returns>Returns the timer object used for this operation.</returns>
        public static Timer PeriodicCall <T>(TimeSpan delay, TimeSpan interval, int count, TimerStateCallback <T> callback, T state)
        {
            Timer t = new StateCallTimer <T>(delay, interval, 0, callback, state);

            t.Priority = (count == 1) ? GetPriority(delay) : GetPriority(interval);
            t.Start();
            return(t);
        }
コード例 #3
0
        /// <summary>
        /// Invokes the specified callback function after the specified delay.
        /// </summary>
        /// <param name="delay">Specifies the amount of time to wait before invoking the callback.</param>
        /// <param name="callback">Specifies the callback to invoke.</param>
        /// <param name="state">Specifies a state object which will be passed to the callback function.</param>
        /// <returns>Returns the timer object used for this operation.</returns>
        public static Timer DelayCall <T>(TimeSpan delay, TimerStateCallback <T> callback, T state)
        {
            Timer t = new StateCallTimer <T>(delay, TimeSpan.Zero, 1, callback, state);

            t.Priority = GetPriority(delay);
            t.Start();
            return(t);
        }
コード例 #4
0
        /// <summary>
        /// Invokes repeatedly the specified callback function on the specified interval and/or delay.
        /// </summary>
        /// <param name="delay">Specifies the amount of time to wait before invoking the first callback.</param>
        /// <param name="interval">Specifies the interval of the repetition.</param>
        /// <param name="callback">Specifies the callback to invoke.</param>
        /// <param name="state">Specifies a state object which will be passed to the callback function.</param>
        /// <returns>Returns the timer object used for this operation.</returns>
        public static Timer PeriodicCall(TimeSpan delay, TimeSpan interval, TimerStateCallback callback, object state)
        {
            Timer t = new StateCallTimer(delay, interval, 0, callback, state);

            t.Priority = GetPriority(interval);
            t.Start();
            return(t);
        }
コード例 #5
0
        /// <summary>
        /// Invokes the specified callback function after the specified delay.
        /// </summary>
        /// <param name="delay">Specifies the amount of time to wait before invoking the callback.</param>
        /// <param name="callback">Specifies the callback to invoke.</param>
        /// <param name="state">Specifies a state object which will be passed to the callback function.</param>
        /// <returns>Returns the timer object used for this operation.</returns>
        public static Timer DelayCall(TimeSpan delay, TimerStateCallback callback, object state)
        {
            Timer t = new StateCallTimer(delay, TimeSpan.Zero, 1, callback, state);

            t.Priority = GetPriority(delay);
            t.Start();
            return(t);
        }