Automatically aborting a dialog

"Erik Ronström (as erik dot ronstrom at doremir dot com)" <[email protected]>
Newsgroups gmane.lisp.lispworks.general
Message-ID <[email protected]>
Hi,

I have this situation:

- The user requests some resource from the internet.
- The request may take a long time to finish, and there is no way to tell when or if it will finish.
- If the request takes very long, after a certain amount of time, I would like to display a dialog saying something like ”This seems to take a long time, do you want to abort or continue waiting?”
- Now, it may happen that the request finishes while the dialog is on screen. In that case, I would like the dialog to automatically close.

What would be a good way to do this?

I have tried this, which works on Mac:

(progn
  (mp:schedule-timer-relative (mp:make-timer (lambda () (mp:process-send (mp:find-process-from-name "Cocoa Event Loop") #'capi:abort-dialog))) 5)
  (let* ((button (make-instance 'capi:push-button :callback (lambda () (capi:exit-dialog t)) :callback-type :none :text "Close"))
         (interface (capi:make-container button)))
    (capi:display-dialog interface)))


The dialog closes after 5 seconds. (It doesn’t work with prompt-for-confirmation, for some reason)


My problems with this approach are that
1) It feels sketchy to retrieve the process by name. Is it guaranteed to always be called ”Cocoa Event Loop”?
2) On non-Mac platforms, how do I even know which process will run the dialog?


Erik



_______________________________________________
Lisp Hug - the mailing list for LispWorks users
[email protected]
http://www.lispworks.com/support/lisp-hug.html
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.