mirror of
https://github.com/dart-lang/sdk
synced 2024-10-14 12:58:05 +00:00
144398d233
BUG= R=terry@google.com Review URL: https://codereview.chromium.org//975213002 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@44241 260f80e4-7a28-3924-810f-c04153c831b5
24 lines
576 B
Dart
24 lines
576 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++;
|
|
});
|
|
} |