Get running process and pending

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
seaniepie
Posts: 154
Joined: Wed Sep 07, 2011 10:56 am

Get running process and pending

Post by seaniepie » Wed Nov 28, 2012 3:39 am

Hi all,

If I use a 'Send "myHandler" in n seconds' which will write some info to a socket but at the same time that it runs (in the n amount of seconds) I have another handler that will need to write to that socket too, is there some way that my second handler can tell if the other is running?
I can tell if it is in the queue to run and I suppose that if it's not in the PendingMessages list then it must be running (or has finished running perhaps). The executionContexts is useful for finding out the current handler and line number but I cant seem to get it to list more than one item, only the one that the 'get the executionContexts' line is actually in.
So, what i'm really asking is Can I Get a List of the Currently Running Handlers? Or is there only EVER the one handler running and the others are held in a queue in the pendingMessages list?

Many thanks

Pi

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: Get running process and pending

Post by Mark » Wed Nov 28, 2012 12:30 pm

Hi ∏,

I don't know of a simple way to retrieve a list of currently running handlers. I also wonder if this is practical, because usually handlers run for only a few milliseconds and your list of running handlers will be empty most of the time.

If a handler needs to know which other handler triggered it with a "send in time" handler, you can send the context along as a parameter:

Code: Select all

put line -1 of the executioncontexts into myContext
send "someHandler myContext" to me in 5 seconds
and you could keep a list of running handlers when they are called:

Code: Select all

global gHandlerList
on someHandler theContext
  put line -1 of the executionContexts & tab & theContext & cr after gHandlerList
  // your script here
end someHandler
Kind regards,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

shaosean
Posts: 906
Joined: Thu Nov 04, 2010 7:53 am

Re: Get running process and pending

Post by shaosean » Wed Dec 12, 2012 11:20 am

why did you hijack this thread? you could have started your own, or looked a couple lines down to this thread http://forums.runrev.com/viewtopic.php?f=9&t=12745

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: Get running process and pending

Post by Mark » Wed Dec 12, 2012 11:38 am

Spammers like to hijack threads!
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

shaosean
Posts: 906
Joined: Thu Nov 04, 2010 7:53 am

Re: Get running process and pending

Post by shaosean » Wed Dec 12, 2012 2:25 pm

They have 1 post, you have over 3900.. ;-)

Post Reply