[Gambas-user] App idle with long loops

Karl Reinl karl.reinl at ...9...
Sun Oct 9 16:34:35 CEST 2016


Am Sonntag, den 09.10.2016, 15:19 +0200 schrieb Jorge Carrión:
> It's an empty proyect, I'm afraid...
> Thanks for the trying.
> 
> Regards
> 
> 2016-10-09 14:36 GMT+02:00 Charlie Reinl <Karl.Reinl at ...9...>:
> 
> > Am Sonntag, den 09.10.2016, 12:56 +0200 schrieb Jorge Carrión:
> > > Is there any example of task fork use? I have a proyect who sending
> > massive
> > > e-mails to our customers and I guess that task can be a good solution...
> > >
> > > Regards
> > >
> > > 2016-10-08 23:54 GMT+02:00 Demosthenes Koptsis <demosthenesk at ...1963....>:
> > >
> > > > 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.
> > > > >
> > > > > 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 at lists.sourceforge.net
> > > > https://lists.sourceforge.net/lists/listinfo/gambas-user
> > > >
> > > ------------------------------------------------------------
> > ------------------
> > > 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 at lists.sourceforge.net
> > > https://lists.sourceforge.net/lists/listinfo/gambas-user
> > >
> >
> > Salut
> >
> > I once found this one :
> > http://gambas.8142.n7.nabble.com/attachment/17635/0/TaskTest.zip
> >
> > It still exists, but don't remember if it worked.
> >
> >
> > --
> > Amicalement
> > Charlie

Salut Jorge,

go to bottom of that page 
http://gambas.8142.n7.nabble.com/gb-task-any-example-td17634.html 

there is the non empty project.

-- 
Amicalement
Charlie





More information about the User mailing list