This project is read-only.

Timer & Timeouts

Syntax

var timeout = new Timeout(time);

Usage

new Timeout(500, true).OnComplete(timeout => Callback());

Example - Start/Pause/Resume

Creates two timeouts. The first is created and paused. The second resumes the first when it is completed.

    var timeout = new Timeout(50);
    
    timeout.Begin += w => { Out.DEBUG(w, "Begin", w.ElapsedMilliseconds, (w as Timeout).Time); };
    timeout.Complete += w => Out.DEBUG(w, "Complete", w.ElapsedMilliseconds);
    timeout.Update += w => { Out.DEBUG(w, "Update", w.ElapsedMilliseconds, (w as Timeout).Time); };
    timeout.Stopped += w => Out.DEBUG(w, "Stopped", w.ElapsedMilliseconds);
    timeout.Paused += w => Out.DEBUG(w, "Paused", w.ElapsedMilliseconds);
    timeout.Resumed += w => Out.DEBUG(w, "Resumed", w.ElapsedMilliseconds);
    
    timeout.Start();
    timeout.Pause();
    
    var timeout2 = new Timeout(500, true).OnUpdate((w) =>
    {
        Out.DEBUG(w, " - Update", w.ElapsedMilliseconds, (w as Timeout).Time);
    }).OnComplete(w =>
    {
        Out.DEBUG(w, " - Complete", w.ElapsedMilliseconds, w.Time);
        timeout.Resume();
    });

Last edited Mar 2, 2010 at 8:59 PM by jgraup, version 1

Comments

No comments yet.