21 lines
444 B
Dart
21 lines
444 B
Dart
import 'dart:async';
|
|
|
|
abstract mixin class Task {
|
|
int get intervalSeconds;
|
|
|
|
String get name;
|
|
|
|
Future<void> task();
|
|
|
|
Future<void> run() async {
|
|
final stopwatch = Stopwatch()..start();
|
|
print('started $name ${DateTime.now()}');
|
|
try {
|
|
await task();
|
|
} catch (e, s) {
|
|
print('error $name ${e.toString()}, stacktrace: ${s}');
|
|
}
|
|
stopwatch.stop();
|
|
print('finished $name, took ${stopwatch.elapsed}');
|
|
}
|
|
}
|