[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Waiting to be the front process...



hello all,

i've got a problem that trial and error (and of course, RTFM-ing) can't
seem to solve, so i'm hoping somebody here can help me. here's the
scenario: my MCL application uses apple events to request an external
program do something for me (in this case: download a file (using FTP)
from a remote site). i've got the apple event stuff set up so that i wait
for the reply - which tells me whether the download was successful or/not,
or was cancelled.

here comes the problematic part: when i send the apple event to the other
process (that program is already running - i make sure of that), i tell it
to bring that other process to the front. that works fine. now, when i get
the reply for that apple event back, i want my MCL application to come
back to the front. that is what i can't get to work.

it seems that i enter my (wait-for-front-process) function (see below) and
no other application ever gets the CPUs attention again. every time i
break into the debugger, i'm in my MCL application, never any of the other
8 processes i have running at the same time. mouse clicks are ignored, and
the only way out is to kill the MCL process - which throws enough sparks
in the surrounding areas that i have to reboot then anyway.

the following is the function that i'm trying to define/call to bring MCL
back to the foreground, waiting until it is the front process. the
(current-process-signature) and (front-process-signature) functions return
the signature for either the current or front process (duh). they both
seem to work, and i don't know how they could be failing in such a way as
to fry my machine the way it gets fried. the
(set-front-process-with-signature ...) function finds the PSN for the
process with the given signature, and calls #_SetFrontProcess with that
PSN. it comes back successfully (apparently) every time. i've tried
wrapping (print ...) around various functions, so i know that it is in
fact looping around, i just can't seem to get it to give the CPU to
anybody else, so they can give up being the front process (or whatever
else they have to do).

(defun wait-for-front-process ()
  (let ((current-process (current-process-signature)))
    (loop
      (event-dispatch t)
      (set-front-process-with-signature current-process)
      (when (eql current-process (front-process-signature))
        (return)))))

what am i missing here? according to the documentation, "event-dispatch"
calls #_WaitNextEvent, so it can't be that...

am i flying in the face of general interface conventions? i realize that
switching from one program to another without user intervention seems
weird, but i do have reasons for doing this. am i SOL?

help!? thanks!

-joey
=====================================================================
Joey Gray                       | geek@nwu.edu
School of Education             | (708) 467-1704
Northwestern University         +------------------------------------
**Bandwagon disclaimer:         | "Anybody can cook with gas --
   My opinions are mine, not my |  it takes the French to cook with
   employer's. so there!        |  magnets!" - old newsreel
=====================================================================