Click here to get back home

Asynch wininet - Threaded or not?

 HomeNewsGroups | Search

microsoft.public.smartphone.developer - Developing software for MS Smartphone? This is your group! 

get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
Asynch wininet - Threaded or not? Fred 02-01-2006
Posted by Fred on February 1, 2006, 9:51 am
Please log in for more thread options
Hi,

If I use asynch Wininet is there any purpose in hiving of the Wininet calls
into separate threads and the extra complication which ensues? As from what
I can see the system starts a separate thread implicitly for the asynch
calls anyway.
The reason I ask is I imagine the thread switching might ensure that the UI
remains responsive - plus there may be other issues you can enlighten me
with.

My application is "real-time" and will be applied to a Pocket PC/Smartphone
as well as WinXP so I need the quickest/most efficient functionality
possible.

Also the UI response must be as fast as possible.

The application basically "GET"s a website for info then issues occasional -
through crucial "POST"s prompted by the user via the UI.

Both the GETS and POSTS must be carried out as close to real-time as
possible.

TIA




Posted by Scherbina Vladimir on February 1, 2006, 4:27 pm
Please log in for more thread options
Hello, Fred.

show/hide quoted text

Even if you use wininet synchronously system might create additional threads
and you cannot control this behavour. So putting async. calls into separate
thread is useless.

You may achieve the fastest result by creating the "worker" thread that
waits on some object (for instance, event) and when GUI thread is going to
make a GET or POST it sets the event and allows worker thread to accomplish
the actual work using syncronous wininet calls.

--
Vladimir



Posted by Scherbina Vladimir on February 2, 2006, 12:33 am
Please log in for more thread options
show/hide quoted text

Documentation states that if you have a thread that is reading or writing
something to/from stream using HINTERNET handle you can close that handle on
another thread using InternetCloseHandle. So if you have you "worker"
sending POST or GET via HttpSendRequest closing HINTERNET handle that is
used in HttpSendRequest will cancel sending request.

--
Vladimir



Posted by Fred on February 2, 2006, 6:31 am
Please log in for more thread options

show/hide quoted text
However
show/hide quoted text
MS
show/hide quoted text
calls.
show/hide quoted text
on
show/hide quoted text

I have read that the cancelling thread MS fix,
http://support.microsoft.com/kb/224318/EN-US/ will cancell all threads
currently accessing the Internet - although I can't find the original
reference which details this.

I have also come across this assertion:

"The async mode is most suited to applications which must be single threaded
and stay responsive to the end user and in extreme performance and memory
sensitive situations"

Although that was in a very old book :)





Posted by Fred on February 2, 2006, 2:40 pm
Please log in for more thread options

show/hide quoted text
threaded
show/hide quoted text
you
show/hide quoted text

Yes as far as synchronous/asynchronous Wininet and multithreading is
concerned.
I have written a pretty complicated prog with a thread pool and synchronous
Wininet and it works - but I'm still not happy about cancelling threads when
we have a timed-out block.

show/hide quoted text
thread.
show/hide quoted text
most
show/hide quoted text

What is the extra complexity involved in writing asynch wininet?

MS's asyncdemo doesn't look too bad

http://msdn.microsoft.com/library/en-us/wininet/wininet/calling_wininet_functions_asynchronously.asp







Similar ThreadsPosted
Re: Asynch wininet - Threaded or not? February 2, 2006, 2:45 pm
SSL with WinINet April 16, 2008, 4:30 pm
WinInet problem August 1, 2005, 1:44 am
Re: Get SEC_E_SECPKG_NOT_FOUND in WinINet until IE has been started March 10, 2005, 2:38 pm
Can wininet functions trigger CM to auto-establish a GPRS connecti June 11, 2005, 10:03 pm

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Driving a better car - Fuelzilla.com

Cabling site for homeowners and pros alike - Cabling-Design.com

Friends:

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap
Privacy Policy