0

I'm trying to use Isolates in Dart. The tutorials from dartlang.org seem to use the function spawnFunction. But that does not seem to work for me. And I cant find any docs about this.

import 'dart:isolate';

void doThing() {
  print('Hello!');
}

main() {
  spawnFunction(doThing);
}

.

Unhandled exception:
No top-level method 'spawnFunction' declared.

The docs from api.dartlang.org mention Isolate.spawn but I get an error saying there is no static method spawn declared.

Did I miss something? A link to appropriate docs (if any) would be appreciated.

Thanks!

4

1 回答 1

1

Isolate.spawn 确实是创建隔离的新方法。您的示例需要重写为:

import 'dart:isolate';

void doThing(_) {
  print("Hello!");
}

main() {
  Isolate.spawn(doThing, null);
}

有关重大更改公告,请参阅https://groups.google.com/a/dartlang.org/forum/#!topic/misc/EVUMkZXFXtY

于 2013-11-09T00:42:39.477 回答