> I was wondering if it was possible to have two call back functions running
> at the same time?
For the same object? No. Different objects can, and usually do, have
different callbacks.
> When I run this program, it seems that once the Start button is pressed,
> the start_call function is executed (which takes a long time) however all
> other buttons/input fields on the form are inactive and the Start button
> remains highlighted (as it is when the mouse is moved over it).
The program is blocking XForms. The callbacks are not invoked with a
signal() type mechanism but basically by polling the X event queue.
If you want to have a long running function in a callback there are
two ways to do it: by using an idle procedure that periodically exits
and returns control to the XForms main loop and event interpreter or
to simply periodically check for events with fl_check_forms().
The second option is easier although (IMHO) not as elegant. To
implement it in your code below:
> int halt_now = 0;
> FILE *fp;
> unsigned long v;
>
> void start_call(FL_OBJECT *w, long q)
> {
> if ((fp = fopen("input_file", "r")) != NULL)
> {
> while (fscanf(fp, "%08x", &v) != NULL)
> {
> /* some code here */
/* Add this here */
fl_check_forms().
> if (halt_now)
> {
> fclose(fp);
> return;
> }
> }
> }
> }
>
>
> void stop_call(FL_OBJECT *w, long q)
> {
> halt_now = 1;
> }
fl_check_forms() simply returns if there are no events to be
processed. Otherwise it processes the event (your stop_call()
callback, for instance) and then returns. Your `halt_now' variable
should be set properly.
Refer to the manual for more detail.
spl
_________________________________________________
To unsubscribe, send the message "unsubscribe" to
xforms-request@bob.usuf2.usuhs.mil or see
http://bob.usuf2.usuhs.mil/mailserv/xforms.html
XForms Home Page: http://bragg.phys.uwm.edu/xforms
List Archive: http://bob.usuf2.usuhs.mil/mailserv/list-archives/