简体   繁体   English

Delphi XE8在应用程序启动时优雅地处理ETetheringException

[英]Delphi XE8 gracefully handle ETetheringException at application startup

The Delphi app tethering manager reserves 20 ports in the range from 2020-2039 to start up its communication threads. 从2020年到2039年,Delphi应用程序网络共享管理器将保留20个端口,以启动其通信线程。 I wanted to find out what happens, when the 21st application is started on the same computer. 我想找出在同一台计算机上启动21st应用程序时发生的情况。 It turns out that this application just hangs unresponsive until it is killed and I haven't found a way to terminate it gracefully. 事实证明,该应用程序只是挂起而无响应,直到被杀死为止,而我还没有找到一种优雅地终止它的方法。

To reproduce, just drop a TTetheringManager and a TTetheringProfile on an empty form, connect the profile to the Manager, compile, start the application 20 times outside the IDE and finally start the 21st instance in the IDE. 要进行复制,只需将TTetheringManager和TTetheringProfile放在一个空的窗体上,将配置文件连接到Manager,进行编译,在IDE外部启动应用程序20次,最后在IDE中启动第21个实例。

This is what I have found out so far: 到目前为止,这是我发现的:

In System.Tether.NetworkAdapter: procedure TTetheringNetworkManagerCommunicationThread.Execute ; System.Tether.NetworkAdapter中:过程TTetheringNetworkManagerCommunicationThread.Execute an ETetheringException.Create(SManagerNetworkCreation) is raised when either the TCP or the UDP communication server could not be started. 当无法启动TCP或UDP通信服务器时,引发ETetheringException.Create(SManagerNetworkCreation) So far so good. 到目前为止,一切都很好。

This exception shows up in the Debugger. 此异常显示在调试器中。 When I continue and step through the following code, the application finally hangs in System: function AcquireExceptionObject and never returns. 当我继续并逐步执行以下代码时,该应用程序最终挂在System:函数AcquireExceptionObject上,并且永不返回。

Since the application is raised during Application.Run, I tried to catch the Exception via: 由于在Application.Run期间引发了应用程序,因此我尝试通过以下方法捕获异常:

try
  Application.Run;
except
  ShowMessage('Something went terribly wrong!');
end;

but this didn't work. 但这没用。 Any suggestions how I can catch (or prevent) this exception? 关于如何捕获(或防止)此异常的任何建议?

由于这确实似乎是一个错误,因此我为此提交了质量报告: https : //quality.embarcadero.com/browse/RSP-11345

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM