3

我正在查看 Isolates 的文档并注意到您可以使用静态方法spawnUri从文件创建隔离。

如此处所示:http: //api.dartlang.org/docs/releases/latest/dart_isolate/Isolate.html#spawnUri

在该文档中,它声明它返回一个返回 Isolate 实例的未来,但是没有其他方法。

有谁知道你是如何使用这个实例在隔离之间来回发送消息的?

当前代码:

 Isolate.spawnUri(Uri.parse(myLibraryFileName),[],"").then((Isolate iso) { 

      // Is there a way of getting the SendPort of the isolate? 
     //Or is there other ways of calling different functions in
     //code (and being able to send messages back to the main isolate)
 });

谢谢你。

4

1 回答 1

1

控制隔离的方法尚未实现。最终,我们希望添加方法来杀死、暂停或检查生成的隔离区。

如果您希望生成的隔离发送回一些东西,您必须在初始消息中发送一个 SendPort。请参阅 BREAKING CHANGE 公告附带的示例:

https://groups.google.com/a/dartlang.org/forum/#!topic/misc/EVUMkZXFXtY

于 2013-11-01T00:50:01.687 回答