Xojo Conferences
MBSSep2018MunichDE
XDCMay2019MiamiUSA

Re: [WE] How do I handle a "Please Wait" window? [Multi-threading in WE] (Real Studio network user group Mailinglist archive)

Back to the thread list
Previous thread: declaring an object with related events
Next thread: MouseEnter and MouseExit


[WE] How do I handle a "Please Wait" window?   -   Greg Olson-Hyde
  Re: [WE] How do I handle a "Please Wait" window? [Multi-threading in WE]   -   Charles Yeomans
    Re: [WE] How do I handle a "Please Wait" window? [Multi-threading in WE]   -   Andrew Keller
    RE: [WE] How do I handle a "Please Wait" window? [Multi-threading in WE]   -   Hodges, Robert CTR USAF AFMC 520 SMXS/MXDEC
    Re: [WE] How do I handle a "Please Wait" window? [Multi-threading inWE]   -   Norman Palardy
    RE: [WE] How do I handle a "Please Wait" window? [Multi-threading inWE]   -   Hodges, Robert CTR USAF AFMC 520 SMXS/MXDEC

Re: [WE] How do I handle a "Please Wait" window? [Multi-threading in WE]
Date: 03.08.11 17:03 (Wed, 3 Aug 2011 12:03:29 -0400)
From: Charles Yeomans

On Aug 3, 2011, at 9:30 AM, Hodges, Robert CTR USAF AFMC 520 SMXS/MXDEC wrote:

> <snick>
> I notice that RS does include DoEvents (Application.DoEvents), but I'm
> curious as to the actual implementation because of how the documentation
> states that it's mainly for console apps and warns that using it in GUI
> apps "will likely cause instability" if used outside of a thread (huh?).
> In VB6, you could use it anywhere with no problems whatsoever, so I'm
> curious about this.
>
> Willing to bet that using Timers and Doevents in RS will come off just
> fine.

Based on my experience with DoEvents, I'll take that bet.

Charles Yeomans
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>

Re: [WE] How do I handle a "Please Wait" window? [Multi-threading in WE]
Date: 03.08.11 16:19 (Wed, 3 Aug 2011 11:19:04 -0400)
From: Andrew Keller
On Aug 3, 2011, at 9:30 AM, Hodges, Robert CTR USAF AFMC 520 SMXS/MXDEC wrote:

> I notice that RS does include DoEvents (Application.DoEvents), but I'm curious as to the actual implementation because of how the documentation states that it's mainly for console apps and warns that using it in GUI apps "will likely cause instability" if used outside of a thread (huh?). In VB6, you could use it anywhere with no problems whatsoever, so I'm curious about this.

In RB, DoEvents invokes the event handler. Instability occurs when multiple DoEvents invocations overlap time-wise. Since the event handler is always running in Desktop and Web apps, it is a very bad idea to call DoEvents at any time. DoEvents is designed for Console applications, where there is no event handler. It allows you to create your own event handler, like there is in Desktop or Web apps.

Here's my two cents: put the working code in a thread on a dialog in the web page. To activate, show the dialog. In the dialog's Shown event, run the thread. At the end of the thread, instruct the dialog to close.

Of course, this assumes that your working code can be threaded. The event handler handles one event at a time, and a chunk of a thread can be conceptually through of as an event (although that is not how it is implemented). The chunk must be completed before the event handler can move on to the next event (or hunk of a thread). This involves completing the hunk, and these hunks are divided at specific places, none of which are in the middle of RB instructions. If the code that creates the PDF is, for example, a declare, that is literally one line of code in RB, and that one line is what is taking so long, then unfortunately, there is nothing you can do. That one line of code will tie up the event handler until it completes, which means that nothing else will get done - including user interface updates - which means you can't update the UI while the process runs. In that case, you may have to get creative. Some people break it off into another program, and access it using an async shell object, however I suspect that might not be of good use here.

~ Andrew Keller

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>

RE: [WE] How do I handle a "Please Wait" window? [Multi-threading in WE]
Date: 03.08.11 14:30 (Wed, 3 Aug 2011 07:30:02 -0600)
From: Hodges, Robert CTR USAF AFMC 520 SMXS/MXDEC
I notice that the Web Edition has Timers, and I suggest using them in
place of Threads. If RS is anything like VB6, then here's some
elaboration on how to do it:

In the "old days" of all my VB6 work, I used to create the equivalent of
threads, pretty much as many as I wanted to, by using (enabling and
disabling) Timers that would run whatever code I wanted. These timers
would run code simultaneously of each other and of any other processes
(in the app or on the system) by way of inserting "DoEvents" in key
places to keep all the "threads" multitasking effectively and playing
nice with each other. Worked great, ran solid as a rock - I created
multi-threaded apps in VB6 for many years using this trick. Meanwhile,
everyone else was criticizing VB6 because it couldn't do
multi-threading, which always gave me a good chuckle because that's
exactly what I was doing (or the zero-noticeable-difference equivalent
of it).

I come across posts to this day about VB6 (or any previous version) not
being able to multi-thread - like people never figured it out. If it
had Timers and Doevents (which I believe goes all the way back to VB4),
then it could multi-thread as smooth as glass. VB4 came out in 1994 I
believe.

I haven't played around in Real Studio long enough to see the difference
between using "Threads" or just using Timers, especially in a web app,
but I'm willing to bet that using either is something very similar to
what I was doing in VB6 and that Timers and DoEvents will be an
effective alternative for any web app.

I notice that RS does include DoEvents (Application.DoEvents), but I'm
curious as to the actual implementation because of how the documentation
states that it's mainly for console apps and warns that using it in GUI
apps "will likely cause instability" if used outside of a thread (huh?).
In VB6, you could use it anywhere with no problems whatsoever, so I'm
curious about this.

Willing to bet that using Timers and Doevents in RS will come off just
fine.


-----Original Message-----
From: <email address removed>
[mailto:<email address removed>] On Behalf Of Greg
Olson-Hyde
Sent: Wednesday, August 03, 2011 4:59 AM
To: Realbasic NUG
Subject: Re: [WE] How do I handle a "Please Wait" window?

On 3 Aug 2011, at 15:43, Bill Reynolds wrote:

> I'd imagine WebDialog (modal) may work for your application, closing
it
> programatically after your operations run.

Thanks for your reply Bill,

Tried that but it is the same - doesn't fire until the PDF process is
complete - unless I have done something wrong! (has been known to
happen!)

Cheers

Greg Olson-Hyde
Sydney Australia

2.8 GHz Quad-Core Mac Pro
Mac OS X 10.6.6
RB 2011r2 Enterprise

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>

Re: [WE] How do I handle a "Please Wait" window? [Multi-threading inWE]
Date: 03.08.11 18:42 (Wed, 3 Aug 2011 11:42:34 -0600)
From: Norman Palardy

On Aug 3, 2011, at 11:11 AM, Hodges, Robert CTR USAF AFMC 520 SMXS/
MXDEC wrote:

> Serious problems, huh?

While it sounds a lot like the VB version the runtimes etc are
different enough that you should avoid using it in a desktop app

Norman Palardy

Real World 2012, THE Real Studio Event of the year!
http://realsoftware.com/community/realworld.php

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>

RE: [WE] How do I handle a "Please Wait" window? [Multi-threading inWE]
Date: 03.08.11 18:11 (Wed, 3 Aug 2011 11:11:16 -0600)
From: Hodges, Robert CTR USAF AFMC 520 SMXS/MXDEC
Serious problems, huh?

-----Original Message-----
From: <email address removed>
[mailto:<email address removed>] On Behalf Of
Charles Yeomans
Sent: Wednesday, August 03, 2011 10:03 AM
To: Realbasic NUG
Subject: Re: [WE] How do I handle a "Please Wait" window?
[Multi-threading inWE]

On Aug 3, 2011, at 9:30 AM, Hodges, Robert CTR USAF AFMC 520 SMXS/MXDEC
wrote:

> <snick>
> I notice that RS does include DoEvents (Application.DoEvents), but I'm
> curious as to the actual implementation because of how the
documentation
> states that it's mainly for console apps and warns that using it in
GUI
> apps "will likely cause instability" if used outside of a thread
(huh?).
> In VB6, you could use it anywhere with no problems whatsoever, so I'm
> curious about this.
>
> Willing to bet that using Timers and Doevents in RS will come off just
> fine.

Based on my experience with DoEvents, I'll take that bet.

Charles Yeomans
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>