Timer in D.API?
Sam Hu
samhu.samhu at gmail.com
Wed Mar 4 16:50:19 PST 2009
Thank you both so much.
In DFL there is a Timer class but I can not get it work:
module dflTimer;
import dfl.all;
import tango.io.Stdout;
class LetterPerSecond
{
private:
Timer timer;
static int counter;
static char[] displayString;
void writeChar(Timer sender,EventArgs ea)
{
Stdout.format("{}",displayString[counter++%displayString.length]);
}
void startTimer()
{
timer=new Timer;
timer.interval=300;
timer.tick~=&this.writeChar;
timer.start;
}
public:
static this()
{
counter=0;
displayString=r"This string will appear one letter at a time.";
}
this()
{
Stdout.formatln("Before timer is starting...");
startTimer;
Stdout.formatln("After timer is ended...");
}
}
int main(char[][] args)
{
auto prog=new LetterPerSecond;
return 0;
}
It compiled but just print 2 lines of message:
Before timer ...
After timer...
I am asking Chris Miller on DFL forum regarding this issue.
In DWT,there is a Runnable class I think it can gain the same result ,but not test yet.
Regards,
Sam
More information about the Digitalmars-d-learn
mailing list