execute method

Future<void> execute()

Executes operation and handles timeout exception

Implementation

Future<void> execute() async {
  isRunning = true;

  if (timeout == null) {
    await operation();
  } else {
    try {
      await operation().timeout(timeout!, onTimeout: onTimeout);
    } catch (e) {
      onTimeout?.call();
    }
  }

  isRunning = false;

  await Future.microtask(() {});
}