Xojo Conferences
XDCMay2019MiamiUSA

Threading (Real Studio network user group Mailinglist archive)

Back to the thread list
Previous thread: Really nasty problems with overlapping controls - in particular cross-platform.
Next thread: Screen to Print and Back Again


Win32 API Declares   -   Berg, Heath
  Threading   -   Bill Cavalieri
   Re: Threading   -   Phil M
   Re: Threading   -   Stefan Pantke
   Re: Threading   -   Jason Toews
   Re: Threading   -   Stefan Pantke
   Re: Threading   -   Brady Duga
   Re: Threading   -   Stefan Pantke
   Re: Threading   -   Bill Cavalieri

Threading
Date: 19.08.05 10:54 (Fri, 19 Aug 2005 04:54:03 -0500)
From: Bill Cavalieri
I have some shell commands that are taking 5-15 seconds to run, which
makes my gui unresponsive for that time of course.

So I need to do that work in a new thread. I'm a bit lost on getting
started.

Do I move my methods to a new thread class, and then call them from run?
Or can I create a new thread class, and then call the existing class
from inside the run event?

Push in the right direction would be appreciated.

-Bill

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

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Re: Threading
Date: 19.08.05 11:41 (Fri, 19 Aug 2005 12:41:27 +0200)
From: Phil M
On Aug 19, 2005, at 11:54 AM, Bill Cavalieri wrote:

> I have some shell commands that are taking 5-15 seconds to run, which
> makes my gui unresponsive for that time of course.
>
> So I need to do that work in a new thread. I'm a bit lost on getting
> started.
>
> Do I move my methods to a new thread class, and then call them from
> run? Or can I create a new thread class, and then call the existing
> class from inside the run event?
>
> Push in the right direction would be appreciated.

You need to either create a new Thread subclass or drag a Thread
instance to your Window. Then you put your Shell code in the Run
event, or have the thread call another method which determines what
shell command to process.

A thread will not run if it is already running, so before you send a
run command make sure you test it's state first:

If Not (MyThread.State = 0) Then MyThread.Run

Be sure to look at the Thread Readme if you are using REALbasic 2005...
there are a lot of new features to control the priority and other
goodies.

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

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Re: Threading
Date: 19.08.05 13:12 (Fri, 19 Aug 2005 14:12:53 +0200)
From: Stefan Pantke

Am 19.08.2005 um 12:41 schrieb Phil M:

> On Aug 19, 2005, at 11:54 AM, Bill Cavalieri wrote:
>
>> I have some shell commands that are taking 5-15 seconds to run,
>> which makes my gui unresponsive for that time of course.

Alternatively, you might wish to subclass the Shell class
and use it in asynchronous mode. In this case, you should
implement the various event, that the Shell class predefines.

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

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Re: Threading
Date: 19.08.05 15:55 (Fri, 19 Aug 2005 07:55:01 -0700)
From: Jason Toews
>>> I have some shell commands that are taking 5-15 seconds to run, which
>>> makes my gui unresponsive for that time of course.
>
> Alternatively, you might wish to subclass the Shell class
> and use it in asynchronous mode. In this case, you should
> implement the various event, that the Shell class predefines.

Amen to that. I had the same exact problem (shell command making gui
unresponsive for 5 seconds or so), and simply switching the shell mode to
asynchronous solved it.

Jason

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

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Re: Threading
Date: 19.08.05 17:42 (Fri, 19 Aug 2005 18:42:56 +0200)
From: Stefan Pantke

Am 19.08.2005 um 16:55 schrieb Jason Toews:

>>>> I have some shell commands that are taking 5-15 seconds to run,
>>>> which makes my gui unresponsive for that time of course.
>>>>
>> Alternatively, you might wish to subclass the Shell class
>> and use it in asynchronous mode. In this case, you should
>> implement the various event, that the Shell class predefines.
>
> Amen to that. I had the same exact problem (shell command making
> gui unresponsive for 5 seconds or so), and simply switching the
> shell mode to asynchronous solved it.

Yes. Most likely, you won't gain much by embedding the Shell in
a Thread - except you have very special requirements. A typical
'Fire the call and get the result' schema should work fine using
async mode.

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

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Re: Threading
Date: 19.08.05 18:13 (Fri, 19 Aug 2005 10:13:52 -0700)
From: Brady Duga

On Aug 19, 2005, at 9:42 AM, Stefan Pantke wrote:

> Yes. Most likely, you won't gain much by embedding the Shell in
> a Thread
>

If by "won't gain much" you mean "will have no impact at all", then
you are entirely correct. :) Threads in Rb are cooperative - they
must yield to other threads (including the main thread). A shell in a
thread will block until completion, unless you go to a lot of trouble
to make an asynchronous thread that sets a flag, then either loop or
sleep in the spawned thread. Of course, that's more work than just
using an asynch shell in the first, and doesn't actually gain anything.

--Brady
The La Jolla Underground


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

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Re: Threading
Date: 19.08.05 18:23 (Fri, 19 Aug 2005 19:23:38 +0200)
From: Stefan Pantke

Am 19.08.2005 um 19:13 schrieb Brady Duga:

>
> On Aug 19, 2005, at 9:42 AM, Stefan Pantke wrote:
>
>> Yes. Most likely, you won't gain much by embedding the Shell in
>> a Thread
>>
> If by "won't gain much" you mean "will have no impact at all", then
> you are entirely correct. :)

Absolutely. My bad english.

Thanks for the hint ;-)

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

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Re: Threading
Date: 20.08.05 08:03 (Sat, 20 Aug 2005 02:03:28 -0500)
From: Bill Cavalieri
On Fri, 2005-08-19 at 14:12 +0200, Stefan Pantke wrote:
> Am 19.08.2005 um 12:41 schrieb Phil M:
>
> > On Aug 19, 2005, at 11:54 AM, Bill Cavalieri wrote:
> >
> >
> >> I have some shell commands that are taking 5-15 seconds to run,
> >> which makes my gui unresponsive for that time of course.
>
> Alternatively, you might wish to subclass the Shell class
> and use it in asynchronous mode. In this case, you should
> implement the various event, that the Shell class predefines.

Thanks, asynchronous mode is just what I needed.

-Bill

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

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>