我正在查看有关隔离的文档,并注意到您可以使用静态方法spawnUri从文件中创建隔离。
如图所示:isolate/Isolate.html#spawnUri
在该文档中,它声明它返回一个未来,其中返回一个隔离实例,但是没有其他方法。
有人知道如何使用这个实例在隔离器之间来回发送消息吗?
现行法典:
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)
});谢谢。
发布于 2013-11-01 00:50:01
控制隔离的方法尚未实现。最后,我们希望添加方法来杀死、暂停或检查生成的隔离。
如果您想要生成的隔离返回一些东西,那么您必须在初始消息中发送一个SendPort。请参阅突破性更改公告附带的示例:
https://groups.google.com/a/dartlang.org/forum/#!topic/misc/EVUMkZXFXtY
https://stackoverflow.com/questions/19715700
复制相似问题