Newsgroups : Microsoft : microsoft.public.inetsdk.programming.wininet : 2008 Apr : WinInet in asynchronous mode vs. Synchronous mode on a a seperate thread
| Subject: | WinInet in asynchronous mode vs. Synchronous mode on a a seperate thread |
| Posted by: | "Roop Goyal" (roop.es..@gmail.com) |
| Date: | Wed, 30 Apr 2008 10:55:44 -0700 (PDT) |
There are two ways to have a timeout in WinInet: asynchronous vs.
synchornous
Asynchronous Way
------------------------
1. Create an asyncronous WinInet session handle (hHandle) by calling
InternetOpen with INTERNET_FLAG_ASYNC.
2. Call CreateEvent to call generate an m_event.
3. Call InternetSetStatusCallback on hHanlde and specifiy
MyStatusCallBack funciton
4. Call WaitForSingleObject(m_event, timeout)
In MyStatusCallBack handle all the events generated by WinInet and
call InternetConnect, HttpOpenRequest, HttpSendRequent and
InternetReadFile at appropriate WinInet events and then signal
m_event.
Synchronous Way
----------------------
1. From the appilcation thread, spawn a new thread T =
CreateThread(..., FetchMethod, ...)
2. WaitForSingleObject (T, timeout)
In FetchMethod make all WinInet calls.
Is there any one who has dealt with both the techniques?
Any comments on the computational load (memory, cpu cycles) comparison
of both the methods?
Any comments on the complexity of asynchronous way WinInet?
Thanks,
Roop