213830e122
R=bkonyi@google.com Change-Id: I3a450b04becaef007cc81fda1dbca1fda58b3d19 Reviewed-on: https://dart-review.googlesource.com/12361 Commit-Queue: Terry Lucas <terry@google.com> Reviewed-by: Ben Konyi <bkonyi@google.com>
25 lines
577 B
Dart
25 lines
577 B
Dart
library async_periodictimer;
|
|
|
|
import 'dart:async';
|
|
import 'package:unittest/unittest.dart';
|
|
|
|
main(message, replyTo) {
|
|
var command = message.first;
|
|
expect(command, 'START');
|
|
int counter = 0;
|
|
new Timer.periodic(const Duration(milliseconds: 10), (timer) {
|
|
if (counter == 3) {
|
|
counter = 1024;
|
|
timer.cancel();
|
|
// Wait some more time to be sure callback won't be invoked any
|
|
// more.
|
|
new Timer(const Duration(milliseconds: 30), () {
|
|
replyTo.send('DONE');
|
|
});
|
|
return;
|
|
}
|
|
assert(counter < 3);
|
|
counter++;
|
|
});
|
|
}
|