perform method
Perform the task in an isolate Optional callbacks for completion and error
Implementation
Future<void> perform({
void Function(T result)? onDone,
void Function(Object error)? onError,
}) async {
await _initWorker();
try {
final result = await workerManager.execute<T>(() async {
return await performTask();
});
if (onDone != null) {
onDone(result);
}
} catch (e) {
if (onError != null) {
onError(e);
} else {
// Default error logging if no callback provided
print("IsolateTask error: $e");
}
}
}