Max Terentiev 0 Posted October 5, 2020 Hi, I create and use TsslHttpCli like this: Http=new TSslHttpCli(NULL); SslContext=new TSslContext(NULL); Http->SslContext=SslContext; Http->OnRequestDone=HttpRequestDone; Http->URL="https://api.server.ru/api/data-list/"; Http->GetASync(); If I call GetASync() can I destroy TsslHttpCli at any time before they fire OnRequestDone event ? For example, if user close program can I run code like this: delete Http; // or Http.Free; on pascal Or I must call TsslHttpCli.Abort or AbortComponent and wait until they ready for destruction (in this case - how to understand is it's ready for destruction)? Thanks for help ! Share this post Link to post
FPiette 383 Posted October 5, 2020 You should not destroy the component from an event handler of that component (general rule, not specific of ICS) or you'll experience access violation or other strange behavior. From an event handler, you can defer the destroy using a PostMessage of a custom message. That is what TForm.Release does by the way. Share this post Link to post
Max Terentiev 0 Posted October 5, 2020 So, I can destroy TsslHttpCli from any another application event (like CancelButton.OnClick, Form.OnClose, etc) without any special care ? No matter is TsslHttpCli idle or process some request ? Share this post Link to post
FPiette 383 Posted October 6, 2020 Yes. The remote site will experience and abort error if a transfer is occurring. Share this post Link to post