The Delphi app tethering manager reserves 20 ports in the range from 2020-2039 to start up its communication threads. I wanted to find out what happens, when the 21st application is started on the same computer. 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.
This is what I have found out so far:
In System.Tether.NetworkAdapter: procedure TTetheringNetworkManagerCommunicationThread.Execute; an ETetheringException.Create(SManagerNetworkCreation) is raised when either the TCP or the UDP communication server could not be started. 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.
Since the application is raised during Application.Run, I tried to catch the Exception via:
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?
OnException
event and handle the exception there. – Apogeotropismprocedure TForm1.FormShow(Sender: TObject); begin try try TetheringAppProfile1.Manager := TetheringManager1; except ShowMessage('Something went wrong here: '); end; finally ShowMessage('Finally made it'); end; end;
– Spoondrift