How to set delay for next statement in xojo web

Hi Guys, I’m new for xojo, My project is web application, I try to set delay in foreach loop, Begin with “DelayMBS”, it a plugin from monkeybread, it didn’t work but on xojo Desktop it’s work. So this my curious, How can I set the delay for wait next statement in xojo web.

  For Each emailItem As JSONItem in self.email
    Dim pe As New Model.PersonEmail
    //DelayMBS
    emailItem.Value("person_id") = rs.IdxField(1).StringValue
    If Not pe.Save(emailItem) Then Return(False)
  Next

Explain a little bit for my code, I had a loop in JSONArray, each round I would like to set a delay before go next about (5000 ms)
Thank You in advance

Use a Timer :slight_smile:

Actually I suggest using a WebThread. It’ll give you the ability to return any feedback to the Session that’s responsible for the processing. Otherwise, you’ll have to deal with things being processed on the main thread. So you’d subclass WebThread and implement the Run event using the code you have above and before the Next call, you’d insert self.Sleep(5000,false). That should get you roughly the same effect.

Just keep in mind that nothing on the web is really synchronous, so a long running process like this has to be async. If you must know the return status, make a Boolean property (or two) on your WebThread class for reportIng status (one for whether or not the process is still running and one for the error condition. Then just periodically check the status using a WebTimer.

It freezes ALL sessions. That is documented by MBS. Don’t use it in a Web app.

[quote=271901:@Greg O’Lone]Actually I suggest using a WebThread. It’ll give you the ability to return any feedback to the Session that’s responsible for the processing. Otherwise, you’ll have to deal with things being processed on the main thread. So you’d subclass WebThread and implement the Run event using the code you have above and before the Next call, you’d insert self.Sleep(5000,false). That should get you roughly the same effect.

Just keep in mind that nothing on the web is really synchronous, so a long running process like this has to be async. If you must know the return status, make a Boolean property (or two) on your WebThread class for reportIng status (one for whether or not the process is still running and one for the error condition. Then just periodically check the status using a WebTimer.[/quote]

Thanks guys for all advice, I Try to follow like Greg O’Lone and I got what I want.

Oh I see, that why when I use “DelayMBS” it hold all action, Thank you