您如何使用Isolate.spawnUri方法来控制隔离?

问题描述 投票:3回答:1

我正在浏览有关隔离的文档,并注意到您可以使用静态方法spawnUri从文件创建隔离。

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

在该文档上,它声明返回的是Future,但返回的是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)
 });

谢谢。

dart dart-isolates
1个回答
1
投票

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

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

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

© www.soinside.com 2019 - 2024. All rights reserved.