Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.sys.acorn.programmer > #280
| From | Martin Wuerthner <spamtrap@mw-software.com> |
|---|---|
| Newsgroups | comp.sys.acorn.programmer |
| Subject | Re: As it's launched, how can a program test if a copy of itself is already running ? |
| Date | 2011-05-05 15:51 +0200 |
| Organization | MW Software |
| Message-ID | <ef58a4ce51.martin@bach.planiverse.com> (permalink) |
| References | <9c9556c5-8dd0-498a-b6f5-6aa531f4be63@d28g2000yqf.googlegroups.com> <c2f1bcd8-56dc-4422-a744-1c24bbcdd8c8@l36g2000vbp.googlegroups.com> <51c90e63f1News03@avisoft.f9.co.uk> <1f0771c951.Alan.Adams@laptop.adamshome.org.uk> <Gkwwp.36775$oP6.7868@newsfe19.ams2> |
In message <Gkwwp.36775$oP6.7868@newsfe19.ams2>
Steve Drain <steve@kappa.me.uk> wrote:
> This is a very late contribution, because I have been away for a month.
> I offer it because I think it rather elegant and it is all my own
> invention. ;-)
> In the wimp poll loop where you handle messages put these WHEN clauses:
> WHEN &400C2:REM TaskInitialise
> IF $(q%+28)=taskname$ AND q%!4<>taskhandle% THEN
> q%!16=&50400
> SYS"Wimp_SendMessage",17,q%,q%!4
> ENDIF
> WHEN &50400:REM TaskRunning
> PROCquit
> * q% is the pointer to the message block
> * the message number &50400 comes from a SWI chunk allocated to me, but
> could be any one you have instead. Alternatively, you could use a number
> from the user chunk with bits 19 and 18 set.
Yes, that is indeed very elegant, but why go to the trouble of
inventing a new message if all you are going to do is quit when seeing
it? We already have a message that does that, so you might just as
well send Message_Quit (0) directly. Since your task has a handler for
that already, you can save the handler for the custom message.
Secondly, the task name at q%+28 is control-terminated, so you should
avoid using $(q%+28) because that only reads the name correctly if it
happens to be CR-terminated.
The downside of this approach is that this still causes the second
task to be fully initialised. It is only quit after reaching its poll
loop, which might be too late.
--
Martin
---------------------------------------------------------------------
Martin Wuerthner MW Software http://www.mw-software.com/
RISC OS Software for Design, Printing and Publishing
---------------------------------------------------------------------
Back to comp.sys.acorn.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
As it's launched, how can a program test if a copy of itself is already running ? Martin Hansen <mhh@shrewsbury.org.uk> - 2011-04-04 00:37 -0700
Re: As it's launched, how can a program test if a copy of itself is already running ? "John Williams (News)" <UCEbin@tiscali.co.uk> - 2011-04-04 09:59 +0200
Re: As it's launched, how can a program test if a copy of itself is already running ? James Lampard <dontreplytothis@mailinator.com> - 2011-04-04 01:39 -0700
Re: As it's launched, how can a program test if a copy of itself is already running ? Dave Higton <davehigton@dsl.pipex.com> - 2011-04-04 20:35 +0100
Re: As it's launched, how can a program test if a copy of itself is already running ? Martin Hansen <mhh@shrewsbury.org.uk> - 2011-04-05 12:13 -0700
Re: As it's launched, how can a program test if a copy of itself is already running ? Martin Hansen <mhh@shrewsbury.org.uk> - 2011-04-07 09:47 -0700
Re: As it's launched, how can a program test if a copy of itself is already running ? Gazza <usenet@garethlock.com> - 2011-04-24 02:58 -0700
Re: As it's launched, how can a program test if a copy of itself is already running ? Martin <News03@avisoft.f9.co.uk> - 2011-04-24 18:32 +0100
Re: As it's launched, how can a program test if a copy of itself is already running ? "John Williams (News)" <UCEbin@tiscali.co.uk> - 2011-04-24 20:35 +0200
Re: As it's launched, how can a program test if a copy of itself is already running ? Alan Adams <alan@adamshome.org.uk> - 2011-04-25 12:29 +0100
Re: As it's launched, how can a program test if a copy of itself is already running ? Steve Drain <steve@kappa.me.uk> - 2011-05-05 13:01 +0100
Re: As it's launched, how can a program test if a copy of itself is already running ? Martin Wuerthner <spamtrap@mw-software.com> - 2011-05-05 15:51 +0200
Re: As it's launched, how can a program test if a copy of itself is already running ? Steve Drain <steve@kappa.me.uk> - 2011-05-05 16:37 +0100
Re: As it's launched, how can a program test if a copy of itself is already running ? Rick Murray <heyrickmail-usenet@yahoo.co.uk> - 2011-05-06 00:32 +0200
Re: As it's launched, how can a program test if a copy of itself is Howard Dawson <hsdawson@ormail.co.uk> - 2011-05-17 20:35 +0100
csiph-web