LB Booster
General >> General Board >> Help With Simultaneous Operations
http://lbb.conforums.com/index.cgi?board=general&action=display&num=1454088928

Help With Simultaneous Operations
Post by Richard Russell on Jan 29th, 2016, 4:35pm

I am temporarily breaking my self-imposed exile because of extreme frustration at the poor quality of some replies I see at the LB Community Forum. There's currently a thread there about how one might do something else while an FTP download is taking place.

The answer given was that this isn't possible in native LB code because it doesn't support multithreading. But this is highly misleading, if not plain wrong. The reason you can't straightforwardly do it isn't because neither LB nor LBB support multithreading but because the URLDownloadToFile API is blocking, that is it doesn't return to the caller until the entire file has been downloaded.

In fact it is relatively straightforward to replace the single call to that API with multiple calls to the InternetReadFile API. That allows you to download the file in chunks of a size that you specify; it might be as little as 1 Kbyte at a time. Now, you can easily 'do something else' while downloading the file, because control is returned to your LB program after each chunk.

You are not actually performing 'simultaneous operations', that would indeed involve not only multiple threads but multiple CPUs, but as far as the user is concerned the effect is exactly the same.

Rant over. I will go and hide in a corner again.

Richard.

Re: Help With Simultaneous Operations
Post by net2014 on Jan 29th, 2016, 7:51pm

Please keep peeping out of that corner Richard wink

Thanks, I now understand the term 'blocking'