似乎有2种情况的bug,
我为套接字声明了一个定时器
private var socketTimer:Timer = new Timer(500,1);
代码1:这段代码在执行NativeProcess
之前花费了几秒钟public function onTimerComplete(event:TimerEvent):void {
socketMonitor = new SocketMonitor('127.0.0.1',8090);
socketMonitor.addEventListener(StatusEvent.STATUS, socketStatusChange);
socketMonitor.start();
}
private function socketStatusChange(e:StatusEvent):void {
if(socketMonitor.available==false && xSo_start==false) {
xSo_start=true;
xSoDump(); //Execute NativeProcess EXE
}
}
代码2(优化):这段代码将立即执行NativeProcess,但几分钟后,NativeProcess将自己挂起,没有任何错误:
public function onTimerComplete(event:TimerEvent):void {
socketMonitor = new SocketMonitor('127.0.0.1',8090);
socketMonitor.addEventListener(StatusEvent.STATUS, socketStatusChange);
socketMonitor.start();
xSoDump();
}
private function socketStatusChange(e:StatusEvent):void {
}
在某些情况下,NativeProcess也会挂起自己,这让我想知道是否有人遇到同样的问题?
NativeProcess
可能会暂停,而它等待您从StandardOutput或StandardError流中读取(特别是如果NativeProcess是命令行应用程序)。这可能就是你所看到的NativeProcess"挂起"。
您应该从StandardOutput/StandardError流中读取以清空缓冲区,即使您实际上没有对数据进行任何操作。
查看文档,了解它们如何处理ProgressEvent.STANDARD_OUTPUT_DATA
和ProgressEvent.STANDARD_ERROR_DATA
事件(以及错误处理程序):
http://help.adobe.com/en_US/FlashPlatform/beta/reference/actionscript/3/flash/desktop/NativeProcess.html includeExamplesSummary
否则,您是否能够提供有关NativeProcess
正在做什么的更多信息?