Main loop
Introducing - the ideal Zune event loop:
: ULONG sigs = 0;
Don't forget to initialize the signals to 0 ... The test of the loop is the MUIM_Application_NewInput method:
: ... : while((LONG) DoMethod(app, MUIM_Application_NewInput, (IPTR)&sigs) : != MUIV_Application_ReturnID_Quit)
It takes as input the signals of the events it has to process (result from Wait(), or 0), will modify this value to place the signals Zune is waiting for (for the next Wait()) and will return a value. This return value mechanism was historically the only way to react on events, but it was ugly and has been deprecated in favor of custom classes and object-oriented design.
The body of the loop is quite empty, we only wait for signals and handle Ctrl-C to break out of the loop:
: { : if (sigs) : { : sigs = Wait(sigs | SIGBREAKF_CTRL_C); : if (sigs & SIGBREAKF_CTRL_C) : break; : } : }