Lisp HUG Maillist Archive

CAPI dialogs and multiprocessing

Hi!

I have a CAPI dialog which performs some network operations when a button is clicked. Since this can take a while to finish, I want to show some visual feedback to the user, for example disable the button just clicked.

(defun send-callback (interface)
  (setf (capi:simple-pane-enabled (send-button interface)) nil)
  … do network stuff ...
  (setf (capi:simple-pane-enabled (send-button interface)) t))

The problem is that the CAPI thread is busy during the network request, and the updates to the interface never become visible.

I've tried to run the network request in a thread:

(mp:process-run-function "Sending data…" nil
     #'(lambda ()
    … do network stuff …
          (capi:execute-with-interface interface #'(lambda ()  (setf (capi:simple-pane-enabled (send-button interface)) t)))

But this makes the program lock, probably a thread deadlock.

Any suggestions?

Regards
Erik


Re: CAPI dialogs and multiprocessing

Hi Erik!

Are you using a function like mp:process-wait just after launching the thread?
I am trying to understand why the CAPI process would block while the other process is running.

On a different subject, I thought you might want to give the possibility to cancel the network operation and account for possible errors, or your button would never become enabled again.  For this, you might want to call (setf capi:simple-pane-enabled) in a function called by a cleanup handler (setup with mp:ensure-process-cleanup).  Maybe you already thought about this, but I believed it was worth letting you know.


Best Regards,
Camille


On Jan 30, 2012, at 2:17 PM, Erik Ronström wrote:

> 
> Hi!
> 
> I have a CAPI dialog which performs some network operations when a button is clicked. Since this can take a while to finish, I want to show some visual feedback to the user, for example disable the button just clicked.
> 
> (defun send-callback (interface)
>  (setf (capi:simple-pane-enabled (send-button interface)) nil)
>  … do network stuff ...
>  (setf (capi:simple-pane-enabled (send-button interface)) t))
> 
> The problem is that the CAPI thread is busy during the network request, and the updates to the interface never become visible.
> 
> I've tried to run the network request in a thread:
> 
> (mp:process-run-function "Sending data…" nil
>     #'(lambda ()
>    … do network stuff …
>          (capi:execute-with-interface interface #'(lambda ()  (setf (capi:simple-pane-enabled (send-button interface)) t)))
> 
> But this makes the program lock, probably a thread deadlock.
> 
> Any suggestions?
> 
> Regards
> Erik
> 
> 


Re: CAPI dialogs and multiprocessing

Unable to parse email body. Email id is 11447

Updated at: 2020-12-10 08:37 UTC