>I have a question here. I built an application for downloading data from
>another device. In the application, I created an infinite loop for getting
>data all the time unless the user push "done" button in order to terminate
>the loop and finish downloading. I did the following steps for making
"done"
>button work. However, when I tested it, it didn't do anything. The infinite
>loop was still running.
>
>static Boolean ldu_handler(EventPtr event)
>{
>  .....
>  case ctlSelectEvent:
>    if (event->data.ctlEnter.controlID == buttonID_ldu_done)
>    {
>      runLoop = 0;
>      FrmGotoForm(formID_main);
>      handled = 1;
>    }
>    break;
>  .....
>  return handled;
>}
>
>static void do_channel()
>{
>  runLoop = 1;
>  while (runLoop)
>

>    .....
>  }
>}


PalmOS is (essentially) a single-threaded system.  Your form handler cannot
be called while you are in an infinite loop, since your loop has exclusive
control.  You have a couple of choices:

1. Don't use infinite loops.
2. Check for events within your infinite loop.

Doing #2 goes something like this:

  while (runLoop)
  {
    if (EvtEventAvail())
    {
      EventType event;
      EvtGetEvent(&event, 0);

      if (event.type == ctlSelectEvent)
      {
        if (event.data.ctlEnter.controlID == buttonID_ldu_done)
          runLoop = 0;
      }
    }
  }
  FrmGotoForm(formID_main); // loop done; goto main form

---- --- -- -
Matthew D Moss
[EMAIL PROTECTED]


Reply via email to