[英]Dart - getting 'Malformed message' in console when spawning multiple isolates
我是 dart 新手,我正在尝试使用隔离运行多个算法以更有效地多次运行它们,但是,当使用 Isolate.spawn 调用多个函数时,我开始在控制台中收到“格式错误的消息”,它仍然有效,但我想知道为什么我会收到此消息,也欢迎任何改进代码的帮助,因为我仍在学习使用隔离的复杂性
stressTest()
{
ReceivePort rpDouble = new ReceivePort();
ReceivePort rpString = new ReceivePort();
ReceivePort rpInteger = new ReceivePort();
int counter = 0;
int tempoTotal = 0;
rpDouble.listen((data) {
counter++;
tempoTotal += data; //data is a stopwatch.toMilliseconds
setState(() { //updating the "progress" and the time it took to run the algorithm in the ui
test = counter.toString() + '%';
_counter = tempoTotal.toString();
});
});
rpInteger.listen((data){
counter++;
tempoTotal += data;
setState(() {
test = counter.toString() + '%';
_counter = tempoTotal.toString();
});
});
rpString.listen((data){
counter++;
tempoTotal += data;
setState(() {
test = counter.toString() + '%';
_counter = tempoTotal.toString();
});
});
for(int i = 0; i < 5; i++) {
Isolate.spawn(DoubleTest, rpDouble.sendPort);
Isolate.spawn(StringStress, rpString.sendPort);
Isolate.spawn(integerTest, rpInteger.sendPort);
}
}
}
DoubleTest、StringStress 和 IntegerTest 是将一个 stopwatch.toMilliseconds 整数返回给 sendPort 的函数。
提前致谢,任何帮助表示赞赏
当您想查看性能应用程序时会发生这种情况。 但是,在重新加载应用程序期间,重新同步数据会导致抖动性能无法获取地址或中断导致该消息的进度阅读器。 这不会影响应用程序或您的应用程序错误。 如果您需要阅读“内存使用情况”或“帧渲染时间”,则只需重新启动 IDE 并重新启动即可。
由于您的代码运行良好,因此您不必太担心错误。 但是,请尝试重新格式化您的代码以避免出现此错误消息。
我的程序中也有类似的问题。 只需在“热重启”完成工作之前保存文件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.