Ejemplo n.º 1
0
        public InternalTimer(int delay, int interval, TimerCallbackDelegate callback, ILogger logger)
        {
            this.delay    = delay;
            this.interval = interval;

            var context = new EventContext <TimerCallbackDelegate>(callback, cb => cb(DateTime.Now), logger);

            timer = new System.Threading.Timer(state => context.Invoke(), null, Timeout.Infinite, interval);
        }
Ejemplo n.º 2
0
    /// <param name="name">Name of the timer.</param>
    /// <param name="duration">Duration you want the timer to run for. (Seconds)</param>
    /// <param name="deleteOnFinish">Should the timer delete itself when finished? (Callback function will still be called)</param>
    /// <param name="callback">Delegate (function) to be called when the timer has finished; use null if no function callback is required. (Function must have no parameters)</param>
    public void Initialize(string name, float duration, bool deleteOnFinish, TimerCallbackDelegate callback)
    {
        m_HasBeenInitialized = true;

        TimerName        = name;
        m_Duration       = duration;
        m_Callback       = callback;
        m_DeleteOnFinish = deleteOnFinish;
        m_OnFinish       = false;
    }
Ejemplo n.º 3
0
 public TimerAbsolute(TimerCallbackDelegate cb) : base()
 {
     if (cb == null)
     {
         throw new Exception("Call back is NULL");
     }
     callback       = cb;
     this.Elapsed  += this.ElapsedAction;
     this.AutoReset = true;
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Creates a new timer.
 /// </summary>
 /// <param name="interval">The number of milliseconds to delay until the callback is called.</param>
 /// <param name="callback">The callback to call.</param>
 /// <param name="param">User data to pass the callback.</param>
 /// <returns>The timer.</returns>
 public static Timer Add(uint interval, TimerCallbackDelegate callback, IntPtr param) => new Timer(Native.SDL_AddTimer(interval, callback, param).Id, callback);
Ejemplo n.º 5
0
 private Timer(int id, TimerCallbackDelegate callback)
 {
     _callback = callback;
     _id       = id;
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Creates an instance of the Multimedia Timer.
 /// </summary>
 public Multimedia()
 {
     _callback  = new TimerCallbackDelegate(TimerCallbackMethod);
     Resolution = 0;
     Interval   = 1;
 }
Ejemplo n.º 7
0
 public static extern MMRESULT TimeSetEvent(uint msDelay, uint msResolution, TimerCallbackDelegate callback, ref uint userCtx, uint eventType);