Although it is true that closing the handle will not stop the thread, it
derived from it. Therefore, your thread will naturally exit ir written
correctly.
I agree that TerminateThread should not be used.
WinInet and InternetCloseHandle.
Post by Scherbina VladimirPost by Paul BakerThere is a big difference in how you write the code. There is not a big
difference in the user's experience, if written properly. Therefore, I
always opt for the thread option. I find the code easier to write and
more reliable.
To cancel the thread, just close the handle on which the blocking thread
is based, or any of its parents.
Just closing handle would not stop your thread. You need to make some kind
of notifications to the thread to allow him "understand" that you want to
terminate it. Sure you may call TerminateThread but this is not
recommended way.
Async. wininet gives you more control over the data tramsmission process.
I've met situations when recieving (or sending) thread is hunging IN
wininet function, and you cannot notify thread to terminate (because
wininet code is executing at this moment) so the only way to stop
processing is terminating thread. In this way you would not make
InternetCloseHandle and another neccessary calls to cleanup resources.
When using wininet in async. way you're able to overcome all above
problems.
--
Vladimir