Welcome Guest. Please Login or Register. Apr 1st, 2018, 04:02am
ATTENTION MEMBERS: Conforums will be closing it doors and discontinuing its service on April 15, 2018. We apologize Conforums does not have any export functions to migrate data. Ad-Free has been deactivated. Outstanding Ad-Free credits will be reimbursed to respective payment methods.
Thank you Conforums members.
Speed up Liberty BASIC programs by up to ten times!
Compile Liberty BASIC programs to compact, standalone executables!
Overcome many of Liberty BASIC's bugs and limitations!
Help With Simultaneous Operations
« Thread started 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.