2016-10-08 23:54 GMT+02:00 Demosthenes Koptsis <demosthen...@gmail.com>: > On 8/10/2016 19:09 μμ, Tobias Boege wrote: >> On Sat, 08 Oct 2016, Demosthenes Koptsis wrote: >>> Hello, >>> >>> i have very long (time consuming) For loops and my app is frozen until >>> loop is finished. >>> >>> for example i wget urls with a custom Sub which Shell("wgetURLS.sh") To >>> sOUTPUT >>> >>> 'get urls >>> For i = 0 To iDepth >>> wgetURLS(i * 10) >>> Next >>> >>> Public Sub wgetURLS(iStart As Integer) >>> ..... >>> >>> Shell("wgetURLS.sh") To sOUTPUT >>> >>> ..... >>> >>> -------------- >>> >>> Is there possible to set the gui idle and the same time run For...loops? >>> >> If you only want to refresh the GUI (e.g. if your For loops update a >> ProgressBar on your form and you want to update the value of that bar >> during the loop), then Wait [1] is sufficient. >> >> If you want the GUI to be fully operatable while your loops run in the >> background, you have to use a background Task [2]. As Gambas is single- >> threaded, Tasks are implemented as external processes which execute one >> of your classes. This limits the things you can do with Tasks (you cannot >> directly modify the main program, for example, but have to send data and >> status reports through a pipe from your Task to the main process and >> interpret them there). However, if all you want is loading some files via >> wget, that should not be a problem. >> >> Of course, there is also the gb.net.curl component which can download files >> asynchronously. If you can use that (which depends on what you want to do), >> you should. >> >> And as a fourth option, looking further into your code: if you want to >> execute shell scripts in a For loop, then don't use the Shell-To syntax >> but create a Process object instead and accumulate its output in Read >> events. The event loop will take care of everything and the GUI will be >> usable without any extra effort on your side. >> >> Finding the best solution depends, who would have thought, on what you want >> to do *specifically*. Tasks are the most general and most cumbersome option. for my feel, i prefers using multiple process objects or if i use httpClient multiple client.
There is an exemple of use in the gb.map source (tilemap) of multiple http server client >> >> Regards, >> Tobi >> >> [1] http://gambaswiki.org/wiki/lang/wait >> [2] http://gambaswiki.org/wiki/comp/gb/task >> > Thanks very much for the details. > > Regards, > > Dim > > > ------------------------------------------------------------------------------ > Check out the vibrant tech community on one of the world's most > engaging tech sites, SlashDot.org! http://sdm.link/slashdot > _______________________________________________ > Gambas-user mailing list > Gambas-user@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/gambas-user -- Fabien Bodard ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, SlashDot.org! http://sdm.link/slashdot _______________________________________________ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user