我在 Dart 中发现了这种非常奇怪和不幸的行为。当我在主文件中导入“dart:html”时,我的 Isolate 停止工作。
使用我的文件“isolate.dart”:
main(){
print('BAM');
}
这将打印“BAM”:
import 'dart:core';
import 'dart:isolate';
void main() {
Isolate.spawnUri(Uri.parse('isolate.dart'), [], null);
}
但这什么也没打印:
import 'dart:core';
import 'dart:isolate';
import 'dart:html';
void main() {
Isolate.spawnUri(Uri.parse('isolate.dart'), [], null);
}
如何在使用 html 导入时让 Isolate 工作?
更新:我找到了此代码https://github.com/TomCaserta/ExampleIsolate并尝试使用它来查找问题。似乎来自 Isolate 的 print() 调用引起了问题。