|
Posted by Fred on February 2, 2006, 2:40 pm
Please log in for more thread options
show/hide quoted text
> Fred,
> Let's discuss what your old book says:
> "The async mode is most suited to applications which must be single
threaded
show/hide quoted text
> and stay responsive to the end user and in extreme performance and memory
> sensitive situations"
> This is technically true, but don't be misled by it!
> If an application must be single threaded, then synchronous mode by
> definition will prevent it from returning to the message loop until it is
> done. However, there is no such application in practice. Who's stopping
you
show/hide quoted text
> from using multiple threads? Nobody! Only your own lack of knowledge about
> multithreaded programming, perhaps.
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
> The rest of it is presumably talking about the expense of creating a
thread.
show/hide quoted text
> It takes a little time and it allocates some memory (the largest part of
> which is the stack). However, these are not really relevant issues for
most
show/hide quoted text
> applications. You're not going to be downloading thousands of web pages at
> once are you?
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
|
> 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