简体   繁体   English

带有TIdTcpServer的TApplicationEvents问题?

[英]TApplicationEvents with TIdTcpServer Problem?

I would like to know if the TApplicationEvents component might cause some problem in case of an exception in the TcpServer OnExecute event, in this case preventing the indy from handling the error correctly. 我想知道在TcpServer OnExecute事件发生异常的情况下,TApplicationEvents组件是否可能引起某些问题,在这种情况下,将阻止Indy正确处理错误。

i mean if use procedure TForm1.ApplicationEvents1Exception(Sender: TObject; E: Exception); 我的意思是如果使用procedure TForm1.ApplicationEvents1Exception(Sender: TObject; E: Exception); event 事件

can it generate problems on TIdTcpServer exceptions? 会在TIdTcpServer异常上产生问题吗?

The TApplication(Events).OnException event is (normally) triggered only for unhandled exceptions that are raised in the context of the main UI thread. 通常仅针对在主UI线程的上下文中引发的未处理异常触发TApplication(Events).OnException事件。 Worker threads do not (usually) trigger the TApplication(Events).OnException event. TApplication(Events).OnException线程通常不会触发TApplication(Events).OnException事件。 A thread would have to manually call TApplication.HandleException() for that to happen. 一个线程必须手动调用TApplication.HandleException()才能实现。 Most threads, including Indy's, do not do that. 包括Indy在内的大多数线程都不会这样做。

TIdTCPServer is a multi-threaded component. TIdTCPServer是一个多线程组件。 Its own events, including its On(Listen)Exception events, are triggered in the context of internal worker threads, not in the context of the main UI thread. 它自己的事件(包括其On(Listen)Exception事件)是在内部工作线程的上下文中触发的,而不是在主UI线程的上下文中触发的。

So, to answer your question, TApplication(Events) will not interfere with TIdTCPServer 's ability to handle is own exceptions. 因此,为回答您的问题, TApplication(Events)不会干扰TIdTCPServer处理自身异常的能力。

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

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