【发布时间】:2012-07-24 06:05:07
【问题描述】:
当使用 spawnUri() 启动新的隔离时,是否可以将命令行参数传递给新的隔离?
例如:命令行:
dart.exe app.dart "Hello World"
在 app.dart 中
#import("dart:isolate");
main() {
var options = new Options();
print(options.arguments); // prints ["Hello World"]
spawnUri("other.dart");
}
在 other.dart 中
main() {
var options = new Options();
print(options.arguments); // prints [] when spawned from app.dart.
// Is it possible to supply
// Options from another isolate?
}
虽然我可以通过它的 SendPort 将数据传递到 other.dart,但我想要的具体用途是使用尚未通过 recievePort 回调创建的另一个 dart 应用程序(例如 pub.dart 或任何其他命令行应用程序)。
【问题讨论】:
-
另一个重用现有 dart 脚本的选项是一个新进程,传入命令行参数,但具体来说,这个问题是关于产生新的隔离
标签: dart dart-isolates