Page 1 of 1

Get running process and pending

Posted: Wed Nov 28, 2012 3:39 am
by seaniepie
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

Re: Get running process and pending

Posted: Wed Nov 28, 2012 12:30 pm
by Mark
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

Re: Get running process and pending

Posted: Wed Dec 12, 2012 11:20 am
by shaosean
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

Re: Get running process and pending

Posted: Wed Dec 12, 2012 11:38 am
by Mark
Spammers like to hijack threads!

Re: Get running process and pending

Posted: Wed Dec 12, 2012 2:25 pm
by shaosean
They have 1 post, you have over 3900.. ;-)