32 lines
No EOL
617 B
Dart
32 lines
No EOL
617 B
Dart
import 'package:oto_cli/oto/data/command_data.dart';
|
|
|
|
class SchedulerInterval {
|
|
|
|
int interval;
|
|
bool activate = true;
|
|
bool progress = false;
|
|
DataBuild build;
|
|
|
|
Future Function(DataBuild build) executeFunc;
|
|
|
|
SchedulerInterval(this.interval, this.build, this.executeFunc) {
|
|
startInterval();
|
|
}
|
|
|
|
void startInterval() async {
|
|
while(activate) {
|
|
await Future.delayed(Duration(milliseconds: interval));
|
|
if(!progress) {
|
|
execute();
|
|
}
|
|
}
|
|
}
|
|
|
|
void execute() async {
|
|
if(activate) {
|
|
progress = true;
|
|
await executeFunc(build);
|
|
progress = false;
|
|
}
|
|
}
|
|
} |