'asyncevents - Set asynchronous event handling on or off'

def asyncevents(self, onoff):

    if (MacOS.runtimemodel == 'macho'):
        raise 'Unsupported    in    MachoPython'
    old = self._doing_asyncevents
    if old:
        MacOS.SetEventHandler()
        MacOS.SchedParams(*self.schedparams)
    if onoff:
        MacOS.SetEventHandler(self.dispatch)
        (doint, dummymask, benice, howoften, bgyield) = self.schedparams
        MacOS.SchedParams(doint, everyEvent, benice, howoften, bgyield)
    self._doing_asyncevents = onoff
    return old
