run<TArg, TProgress, TResult> static method

Future<TResult> run<TArg, TProgress, TResult>(
  1. Future<TResult> task(
    1. TArg arg,
    2. void emit(
      1. TProgress
      )
    ),
  2. TArg arg, {
  3. void onProgress(
    1. TProgress
    )?,
})

Spawns an isolate, runs task, and returns its result.

onProgress fires on the calling isolate each time the task calls its emit callback. Throws KIsolateException on spawn failure or an uncaught exception inside task.

Implementation

static Future<TResult> run<TArg, TProgress, TResult>(
  Future<TResult> Function(TArg arg, void Function(TProgress) emit) task,
  TArg arg, {
  void Function(TProgress)? onProgress,
}) => KIsolate<TArg, TProgress, TResult>._()._execute(task, arg, onProgress: onProgress);