Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ames!amdcad!sun!pitstop!sundc!seismo!uunet!munnari!bhpese!Spengat!urs From: urs@Spengat.oz (Urs Ruegger) Newsgroups: comp.sys.amiga.tech Subject: Re: Ultimate Wait-GetMsg strategy (?) Message-ID: <408@Spengat.oz> Date: 17 Feb 89 17:44:13 GMT References: <890204105857.21000bb9@elcc.epfl.ch> <494@infohh.rmi.de> Organization: Spengat Systems, Newcastle Lines: 26 In article <494@infohh.rmi.de>, shimoda@infohh.rmi.de (Markus Schmidt) writes: > Hi! > > Every time using a Wait-GetMsg-pair I thought how to do it > best way. Now I think I got it: > > while (1) { > while (!(imsg= GetMsg(win->UserPort))) > Wait (1<UserPort->mp_SigBit); > ... select imsg->Class and break when ended ... > > } Why not use : while (WaitPort(win->UserPort) { msg = GetMsg(win->UserPort); ...... ReplyMsg(msg); if (xyz) break; } WaitPort() will return as long as there are _any_ messages in your port. Only if the port is empty will it wait for the ports SigBit. Of course this will only wait for one single port, but so does your example.