mms@genmri.UUCP (Mark Scoville) (06/19/91)
I am attempting EXPLICIT DISPATCHING, and am failing sorely! After invoking the application, I toggle back and forth about 3 times or so between 'Start Loop' and 'STOP'. At some point it hangs on STOP. ================================= SPARCstation 1/2 SunOS 4.0.3/4.1 XView 2.0 DevGuide 1.1 OW 2.0 ================================= Thanks in advance. ********************************************** * Mark Scoville (415) 683-4332 * * mms@nmri.ge.com -OR- ...!sane!genmri!mms * ********************************************** ---------------------------- code fragment ------------------------- int flag = FALSE, looper = 0; Display *dpy; void main(argc, argv) int argc; char **argv; { ntf_window1_objects *ntf_window1; /* Initialize XView. */ xv_init(XV_INIT_ARGC_PTR_ARGV, &argc, argv, 0); INSTANCE = xv_unique_key(); /* Initialize user interface components. */ ntf_window1 = ntf_window1_objects_initialize(NULL, NULL); dpy = (Display *)xv_get(ntf_window1->window1, XV_DISPLAY); xv_set(ntf_window1->window1, XV_SHOW, TRUE, NULL); XFlush(dpy); /* Turn control over to XView. */ while(looper < 1000) { notify_dispatch(); XFlush(dpy); LoopFct(ntf_window1); } exit(0); } /* Notify callback function for `button1'. */ void FctDoLoop(item, event) Panel_item item; Event *event; { ntf_window1_objects *ip = (ntf_window1_objects *) xv_get(item, XV_KEY_DATA, INSTANCE); switch (flag) { case FALSE: xv_set(ip->button1, PANEL_LABEL_STRING, "STOP", NULL); flag = TRUE; notify_stop(); break; case TRUE: xv_set(ip->button1, PANEL_LABEL_STRING, "Start Loop", NULL); flag = FALSE; break; } } LoopFct(ip) ntf_window1_objects *ip; { char val[20]; while (flag) { notify_dispatch(); XFlush(dpy); sprintf(val, "%d", looper++); xv_set(ip->textfield1, PANEL_VALUE, val, NULL); } return(0); } ------------------------------ end code fragment -----------------------------
gordonc@aifh.ed.ac.uk (Gordon Cameron (RA DAI)) (06/21/91)
From article <9106191549.AA25895@genmri.sane.COM>, by mms@genmri.UUCP (Mark Scoville): mms@genmri.UUCP (Mark Scoville): > I am attempting EXPLICIT DISPATCHING, and am failing sorely! After invoking > the application, I toggle back and forth about 3 times or so between 'Start > Loop' and 'STOP'. At some point it hangs on STOP. I find that explicit dispatching seems to work some of the time, and not at other times. It seems that you have to watch that you are doing your dispatching before you clear the input buffer. If you have a fast loop that issues a dispatch, but does a colurmap flush, or screen update or something in between dispatches, then the whole thing seems to fall down, and the notifier hangs completely. The solution for me is that I now use XView timers. When an event occurs and I want to start doing something which I might want to abort, I start a timer, and the bit of code going. Now I don't have to worry about stopping and starting the notifier, as my timer function simply checks to see if a flag has been set by pressing a button. If so, then the timer stops, and your application aborts. ( See timers section in O`Reilly, Volume 7 ) I reckon explicit dispatching just does not work properly. Hope this is helpful, Gordon Cameron/ Andrew Fitzgibbon, Dept. of AI, Edinburgh University. e-mail : gordonc@uk.ac.ed.aifh