>I have a multi-threaded application that uses a dynamically created
> THttpCli synchronously. I know that ICS is normally used
> asynchronously, but I could not determine a good way to handle that
> with all the dynamically created threads I have to use for database
> access anyway.
>
> When I want to terminate the thread normally or when I force it to
> terminate I call the THttpCli.Abort method. How can I insure that the
> THttpCli component is indeed aborted before freeing it and ending the
> thread?
>
> Right now I do:
> HTTP.Abort;
> while HTTP.State<>httpReady do
>  Sleep(10);
>
> Is this incorrect, unecessary or adequate?
>
> I was getting some ICS errors when freeing the thread which may have
> been related to freeing the THttpCli or the underlying receive stream.
>
> Thanks,
>
> -Johnnie Norsworthy

Johnnie,

I did the same thing (except for the sleep) but keep getting troubles with 
the abort (hangs). The sleep I did not because I called the abort outside 
the thread and you don't want to sleep the main thread!  I guess you also 
call it outside the thread as you use a sync call in the thread :-)

I changed to async calls but with the http.CtrlSocket.MessageLoop to mimic 
sync behaviour. And for the abort I then used the 
PostMessage(Http.CtrlSocket.Handle, WM_QUIT, 0, 0) to kill it. Never had any 
troubles again!

Nice thing is that my multihreaded app is now showing much beter cpu load 
then with the sync call !


-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://www.elists.org/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be

Reply via email to